// to delete a local branch
$ git branch --delete <<local_branch>>
or
$ git branch -d <<local_branch>>
// To delete a local un-merged branch
$ git branch -D <<local_branch>>
// to delete a local remote - tracking branch
$ git branch --dr <<remote>>/<<branch-name>>
// to delete a remote branch
$ git push --delete <<remote>> <<branch-name>>
* find the common parent as the inital state
* $ git checkout -b <<cherry-pick-branch-name>> <<initial-commit-id>> // create a new branch for cherry-pick
* $ git cherry-pick <<commit-id-wanted>> // select the commit that you want
* Fix any conflicts that arrise
** $ git cherry-pick --continue // to proceed on cherry-pick
* git push <<remote>> <<cherry-pick-branch-name>>
$ git log --oneline --decorate <branch>
$ git show --name-only <commit-id>
$ git log -5 --follow <file-path>
$ git checkout <commit-id> -- <file-path>
$ git reset HEAD <file-path>
$ git diff --cached <file-path>
$ git diff <old-commit-id> <new-commit-id> <file-path>
$ git stash save --keep-index
$ git add --patch <file-path>
* reset head softly locally first
$ git reset HEAD~1
* push forcefully to remote repo
$ git push <<remote>> <<branch>> -f
# To list right-only branch commits that are not in the develop (left branch)
$ git log --cherry-pick --right-only --no-merges develop...master
# To list left-only branch commits that are not in the master (right branch)
$ git log --cherry-pick --left-only --no-merges develop...master
# change dir to the destination branch
$ git checkout <<destination_branch>>
# fetch the tags from the remote
$ git fetch --tags origin
# do merge tag
$ git merge <<tag_name>>
// fetch commits based on commit messages
git log --all --oneline --decorate --grep "message"
// fetch commits based on author and commit message
git log --oneline --author="authorName" --grep "messageStr"
// to display all the files for a specific commit id
git show --name-only f2c06ff6
// to display the commit contents of a file on a specific commit
git show -p <commit-id> -- <filename>
// to display all commit ids along with author name
git log --format='%H %an'