Few Basic Git Commands You should know

Richa Sharma
2 min readApr 20, 2020

--

  • Git is an Open Source Distributed Version Control System.
  • In day to day life developer Git is work as a content tracker.
  • In Project teams we have multiple developers working in parallel. So a version control system like Git is needed to ensure there are no code conflicts between the developers.
  • It is mostly used to store code due to the other features it provides.
  • Few Git commands you should know are as follow:-
  1. git init :- This command is used to create a git repository.
git init

2. git config :- This command is used to set Git configuration values on a global or local project level.

git config user.email

3. git clone :- This command is used to point to an existing repo and make a clone or copy of that repo at in a new directory, at another location.

git clone <:clone git url:>

4. git status :- This is most useful command.It is used to displays the state of the working directory and the staging area. It lets you see which changes have been staged, which haven’t, and which files aren’t being tracked by Git.

git status

5. git add :- This command used to add changes in the working directory to the staging area. With the help of this command, you tell Git that you want to add updates to a certain file in the next commit.

git add . //if you want to add files you have changed

Note : if you want to add particular file you can provide its path with this command.

6. git pull :- This command used to fetch and download content from a remote repository and immediately update the local repository to match that content.

git pull

7. git push :- This command used to upload local repository content to a remote repository. Pushing is how you transfer commits from your local repository to a remote repo.After using this command your local changes will get pushed to remote repo.

git push

8. git commit :- This command used to save your changes to local repo.After adding your local change files you need to commit your file.

git commit -m "<message>"

you have to provide a message with this command.

9. git branch :- This command is used to check the list of branches you have.It will list out all the branches.

git branch

10. git checkout :- This command is used to navigate between the branches created by git branch .

git checkout <branch>

11. git merge :- This command used to merge two branches.Suppose you have worked on one subtask branch you want to add it to main story branch you have use to git merge.

git merge <branch want to merge>
  • Command to create a branch :
git checkout -b [branch name]// you will get switch to new branch

These are few basic git command you should know.

Happy Reading :)

--

--

No responses yet