Using Git – Common Terminal Commands

Hi ,

As we know in current industry one of the most important aspect of development cycle is the use of code version tool.

We have different options in the industry, the most common one are :

  • SVN
  • GIT

Both of these have enormous number of users in the industry, whereas GIT is coming out to be a more preferred choice for developers across the globe. This post is just a basic kickabout stuff that will be required to get you started with GIT over Linux/Unix, A set of commands commonly used for operating GIT over the terminal which has been my preferred choice rather than the tools that are available with a GUI.

So lets get started.

git init – This creates a new local repository on the machine.

git clone path – The command creates a clone to the repo on the local machine.

git add <file> – Add the untracked files to the repository

git add *  – Add all the untracked files to the repo.

git add -i – Opens up a menu that allows the user to enter a choice over the command line tool.

git status – Provides the status of the working directory

git commit -m “Message” -Commit the untracked changes to the repository branch.

git commit -a -m “Message” – Commit and Add all the tracked/untracked files to the repo.

git push branch_name – push the changes to the remote branch

git pull – pull the content from the remote repo.

git checkout <branch_name> – checkout a particular branch.

git checkout -b <branch_name>  – creates a new branch and switch the to the branch simultaneously.

git merge <branch_name> – merge the branch into your current branch.

The above listed are the most used commands for interacting with GIT.

Hope the content above helps.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s