-
Describe a change number
$ git show dc54076
-
Reset the current branch with HEAD of master
$ git fetch origin $ git reset --hard origin/master
-
Keep your branch in sync with origina master branch
$ git pull origin master
-
Arrange all changes in order. Fixes the log too.
$ git rebase origin wip_my_work
-
Squash commits in one commit. 2 represents number of commits to review.
$ git rebase -i HEAD~2
-
Compare two branches
$ git diff master..my_branch
-
Modify a commit message
$ git commit --amend
-
Find diff of local file against remote master
$ git fetch origin master $ git diff origin/master -- [local-path]
-
Elaborate comment amend techniques
-
Stash current commits
$ git stash $ git stash list $ git stash apply stash@{0}
-
Recover/ revert a file to original/master copy
# For a committed file $ git checkout origin/master filename # For a local, uncommitted file $ git checkout -- filename
-
Delete a local branch
$ git branch -d branch_name $ git branch -D branch_name
-
Squash local commits
$git reset --soft HEAD~3 && git commit
-
Delete files from staging
$ git reset file_name
-
Pull master’s changes to your local branch
$git checkout my_branch
$git rebase master
-
Push your local branch changes to master branch
$git checkout my_branch
$git merge master
-
Alias to add and commit a changed file
$ git config --global alias.c "!git add -A && git commit -m"
Advertisements