Thursday, 14 July 2016

git commands

Initial Setup
git config --global user.name "John Doe"
git config --global user.email "johndoeabc123@gmail.com"
git config --list


1. Undo Last commit
$ git reset --soft HEAD~1

2. Delete a local branch
$ git branch -d the_local_branch

3. Delete without merging
$ git branch -D the_local_branch

4. Checking logs
$ git log --oneline
$ git log some-file.cpp
$ git log --oneline some-file.cpp
$ git log --author "Navjot Singh"
$ git log --since=12-18-1979
   (mm-dd-yyyy)
$ git log --author "Navjot Singh" --since=12-18-1979
$ git log --since=12-18-1979 --until=12-30-2016

5. Line changed/added/deleted between 2 commits
$ git diff --stat 36baf22 6edb550

6. Diff between two commits
$ git diff 36baf22 6edb550

No comments:

Post a Comment