Git – Quick reference

Clone a Repository

git clone [url]

 

git status

git add .

git status

git commit -m “comment”

git status

 

git pull origin master {Fix merge issues}

 

git stash

Git stash pop / git stash apply

Git stash apply –index

Git stash list {If there are conflicts}

Git stash drop stash@{0}

 

Then send for peer review

Branching

Git branch

Git branch -a {list remote branches as well}

git checkout branch_name

git checkout -b feature_new-branch-name {create a new branch}

git branch -d branch_name         {delete a branch}

git branch -D branch_name        {Force Delete}

 

RENAMING A BRANCH

git branch -m feature_old_name feature_new_name

GIT UNDO

  1. git clean -fd
  2. git checkout . – Removes Unstaged Tracked files ONLY [Type 2]
  3. git clean -f – Removes Unstaged UnTracked files ONLY [Type 3]
  4. git reset –hard – Removes Staged Tracked and UnStaged Tracked files ONLY[Type 1, Type 2]
  5. git stash -u – Removes all changes [Type 1, Type 2, Type 3]

Leave a Reply