10

sidtechtalks.in

GIT

Commands CheatSheet

init

GIT

If you are creating the new local repository or if you want to create the new directory in a specific project, then you need to initialize git; only then you will be able to commit or adding the files.

git init

Commands

If you want to copy the directory from remote directory then use:

git clone <repo url>

clone

GIT

Commands

This command returns the current state of the repository. If your files are in the staged area and not committed yet, then git status shows your files.

git status

status

GIT

Commands

It helps to add the files in the staged area for Git. We can perform git add in various ways, like if you want to add the whole directory or multiple files or all files.

git add [file1] [file2]

ADD

GIT

Commands

It creates the changes made to the files and saves them to the local repository.  It has created the commit’s unique ID. Add some message at the time of the commit to get to know the other team members about the change.

git commit -m "MESSAGE"

commit

GIT

Commands

It is used to switch the branch to another branch.

git checkout BRANCH_NAME

checkout

GIT

Commands

git checkout -b NEW_BR

For create new branch

To get the latest version of the repository. It would be up to date your local repository to the same as on remote repository.

git pull origin <branch>

PULL

GIT

Commands

It pushes the local changes of the repository to remote repository.

git push origin <branch>

push

GIT

Commands

git push -u origin <branch>

Using upstream, push the local changes as the new branch of the remote repo if not exist.

This command will temporarily store the changes which are not yet ready to commit and give a clean working directory.

git stash

stash

GIT

Commands

git stash pop

You can use these change later or any time in the current branch by using pop

So, that’s all about the basics as well as important GIT commands that developers should know. Learn more commands in detail. It will help you to grow and gives you an idea of Version control system.

Read More

GIT

Commands