Github Magic Commands

Merge the feature branch into master, before pushing.

git checkout feature_branch
 git rebase master
 git checkout master
 git merge --squash feature_branch

Undo a git commit –amend ref

git reset --soft HEAD@{1}
git commit -c HEAD@{1} 

Undo (almost) anything : ref

git reflog
git reset 'HEAD@{1}' # based on the value in reflog you wanna revert to.

Diff 2 git branches : ref

git diff branch_1..branch_2 # if only want to see the difference in tips
git diff branch_1...branch_2 # if wanna see all diff from common ancestor

List all files in a commit : ref

git diff-tree --no-commit-id --name-only -r

Remove specific commit : ref

git rebase --onto ~ ~ 

See file diff against it’s last change : ref

git log -p [--follow] [-1] 

Soft Undo last commit

git reset --soft Head^1 

Hard Reset a file : ref

 git checkout HEAD -- my-file.txt 

Pull Remote Branch ref

git fetch #to sync branch with all remote references
git branch -r # to see all remote branches : -a to see ALL branches (remote + local)
git checkout --track -b origin/branchName

Push to new remote branch ref

#Short Version
git checkout -b
git push

#Longer Version
git push :

#With tracking
git push -u 

Git diff in staged area ref

git diff --staged #( or --cached)

Delete remote branch ref

git push origin --delete 

Cherry pick command from different repo in a folder to current repo ref

git --git-dir=..//.git \
format-patch -k -1 --stdout | \
git am -3 -k

Git clone only one branch ref

git clone git@bitbucket.org:project/project.git -b develop_one --single-branch

Git push local branch to remote

git push -u origin branch_name