Open In App

Basic Git Commands with Examples

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. 



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.

Article Tags :
Git