Git FAQ
-
git clone
into an existing folder?git clone https://myrepo.com/git.git temp mv temp/.git code/.git rm -rf temp
-
Push git commits & tags simultaneously
git config --global push.followTags true
If set to true enable
--follow-tags
option by default. You may override this configuration at time of push by specifying--no-follow-tags
. -
Undo last commit
git reset HEAD~ << edit files as necessary >> git add ... git commit -c ORIG_HEAD
-
Syncing a fork
git remote add upstream https://github.com/ORIGINAL_OWNER/ORIGINAL_REPOSITORY.git git fetch upstream git checkout master git merge upstream/master
-
Merging vs. Rebasing
https://www.atlassian.com/git/tutorials/merging-vs-rebasing
The golden rule of
git rebase
is to never use it on public branches.By default, the
git pull
command performs a merge, but you can force it to integrate the remote branch with a rebase by passing it the--rebase
option. -
Show last commit diff
git diff HEAD^ HEAD
-
Show last commit files
git diff-tree --no-commit-id --name-only -r $(git rev-parse HEAD)
-
Stash with untracked files
git stash --include-untracked
-
Delete branch
git branch -d the_local_branch git push origin --delete the_remote_branch git remote prune origin
-
Unicode filenames
git config --global core.quotePath false
-
Diff only commits
git log --oneline --graph master..feature
-
Diff only filenames
git diff --name-only master