Nowadays open source contribution is on the peak. It’s getting so much popular among students and there are also some open-source programs and competitions to learn so much about development. Open source is a great way to learn and make a better community. There are so many organizations where one can contribute and learn. For that one have to know about using git commands. As a complete beginner, It might be a little difficult for someone to learn a huge number of git commands. So here is the solution. Below, you can get 6 simple git commands with that you can start open-source contributions in any organization.
cd <file path> command
First, you have to create a file where your code will be stored on your pc. For that, you have to create a file on your desktop. After that open Git Bash and type cd <File directory> to go to file and branch.
git clone command
If you want to open-source contribution. First, you have to copy an existing repository (the repository, where you want to contribute) on your local repository (Your repository). For that, you have to click the fork button on the repo of the existing repository on GitHub.
- What is forking: Forking any repository means make a copy of a real repository in your GitHub account and make changes in your copy. Thus, a real repository won’t get affected by your code changes. (After that you have to make a pull request to the real repository for merging your code change, we will come to that part later)
- How to do fork: Just go to the real repo and tap on the fork button
- Copy URL: Then a copy of real repository will be created in your local repository. After that, you have to copy the URL from your local repo. For doing that click to code and copy the URL.
- After that, you have to create a file on your desktop. Then open Git Bash and go to the file using cd command and click enter and type git clone <copied url> to copy the code in your desktop file. With that, you are able to get the code on your desktop.
git status command
After making code changes you have to add the files for that you have to check which files are not added. For that use git status. The command git status can show you the status of your current file whether it is added or committed or pushed.
git add <File name> command
When you get to know which files are not added by typing git status(red-colored files are not added). Then type git add <file name> to add files.
git commit -m <message> or git commit -am<message> command
After that, you have to commit those added files (type git status to check status, and green colored files are not yet committed). Type git commit -m <message> (message is nothing but a text that tells about what is changed in files) (there are many types of commit command you can check out git documentation in git official website).
git push command
At last, you have to push your code changes in your local repo by typing git push and then make a pull request.
- How to make a pull request: After pushing your code to your local repository you have to make a pull request to merge your code to the real repository. To do that just go to your local repo and click on the pull request.
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.