Git

is a open source version control system to manage large scale or small scale projects. If your team is using Git, you do not have to train new hires on your workflow, because they’ll already be familiar with distributed development. Unlike SVN, Git is distributed version control system which generated local copy of remote repository into local for each developer. Merging and managing multiple branches is quite easy. Here are some useful git commands each developer need to know before using git.

Useful git commands - Sgeek

git init

git init is used to initialise repository in local system. It’s very first command to start working with git.

git pull

It updates change to local repository from remote repository.

git commit

git commit command is used to save changes in your local system with note.

Syntax:git commit -m "[Your message]"

git add

This command is used to add files to commit changes on local repository. It also allows you to add multiple files at a time.

Syntax: git add [File path - 1] [File path - 2]

git push

This command is used to update local commits to remote repository.

Syntax:git push origin "[Git Branch Name]"
Steps:
git add [File path you want to commit]
git commit -m 'Test commit'
git pull --rebase
git push origin master

git status

git status command shows changes done on local repository. It list out all the files which are modified, deleted or added in local repository.
Syntax: git status

git branch

It list out all the branches fetched from remote repository.

Syntax: git branch

git checkout

git checkout checkout file or branch from remote repository to local repository.

Syntax:
git checkout [File Path] // checkout file
git checkout [Branch Name] // checkout branch

git fetch

fetches data from remote to local repository

Syntax:
git fetch

git rm

This command is used to remove single or multiple files from repository

Syntax:
git rm [File Path]

git log

Show commit logs with details such as date time on which files commit and tags

Syntax:
git log

git stash

Temporary removes all the uncommited changes from local repository. User can retrieve changes by git stash apply.

Syntax:
git stash

git stash apply

Restores stashed changes into local repository.

Syntax:
git stash apply

There are many more git commands expecting above command. I will update article later with new commands. Don’t forget to share article on social media and your developer friends.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes:

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">