Last Updated: September 09, 2019
·
691
· jaymabazza

Usefull GIT commands

If you're using Mac, i highly recommend Atlassian's SourceTree

Picture

If you're an authentic geek and wants to stick with command line, below are a few commands if you're beginning with git.

git add all and commit in one line

git commit -a -m "added a bunch of awesome features"

git add a file, but you want it on gitignore instead

git rm --cached file.php

git added too early, you want a couple of more codes before push

git add forgotten-file.php
git commit --amend

unstage a file

git reset HEAD file.php

adding terminal colours

git config --global color.status auto
git config --global color.branch auto
git config --global color.diff auto

git shortcuts using bash_profile

Open your ~/.bash_profile and add the following

alias gs='git status '
alias ga='git add '
alias gb='git branch '
alias gc='git commit'
alias gd='git diff'
alias go='git checkout '

Next, you should source for your new configuration to take effect

$> source ./~bash_profile

Now enjoy the shortcuts like so

$> ga file.php