/posts

Why you should learn Git

Git #

Git is a great version control system, which makes it easy to manage different versions of your programming project. I use git not only for my programming projects, but also for publishing Website Blog Posts like this. Instead of getting access to your server and upload your files, which can be very annoying, a git push will do the magic.

Commands #

Here are some really useful git commands for daily use.

Simple standard workflow:

Bash
git pull
git add <some file>
git commit -m 'comment'
git push

Show commits and changes #

Bash
git show

Show remote config of git repository #

Bash
git remote -v

Remove last pushed commit #

uncommit last commit

Bash
git reset --soft HEAD^ 
Bash
git push origin +master

Git Configurations #

View your system, global and local configuration. Git configuration variables can be stored at three different levels. Each level overrides values at the previous level. You can specify your scope with the parameters --system, --global, --local.

Bash
git config --list

Example, set global user.name

Bash
git config --global user.name xyz

Change your url endpoint origin

Bash
git remote set-url origin git@github.com

Let git save your credentials. Can be useful if you are accessing the Repository via https and don’t want to enter your password every time.

Bash
git config --global credential.helper store 

References #

For more look into the official documentation of git: