git reset --soft HEAD~1
git add file.cpp
git commit --amend
n = number of commits to squash
git reset --soft HEAD~n
git commit -m "New message"
Move all your commits that haven't been pushed yet to a new branch! From master...
# create new branch with this history
git checkout -b feature-branch master
# go back to parent branch
git checkout master
# reset this branch's history back to origin
git reset --hard origin/master
git log <parent-branch>..
git show --name-status <commit_sha>
--follow flag is useful if filename has changed
git log --follow file.cpp
git log -p file.cpp
git diff master develop -- file.cpp
git tag 0.1
git push --tags
git show-ref --tags
git checkout foo
git checkout -b foo
i.e. if you're on feature-something
but want to create a new branch based on develop
git checkout -b feature-new develop
git branch -d branch-name
git branch -D branch-name
git push origin :branch-name
If you want to clean up a bunch of branches and want to know what has been merged so you know what you can safely delete
git branch --merged
git remote -v
git branch -vv
From the branch you want to modify..
git branch -u remote-name/branch-name
You need to do this the first time you push a newly created branch
git push -u remote-name/branch-name
Useful if you maintain an addon on your account, and a fork somewhere else (e.g. you've forked your repo into your company's account) and want to keep both in sync without needing to push twice
git remote set-url --add --push <new-remote-url>
git submodule add http://server/path.git
# or if you want to specify the folder and/or path/to/folder to clone into
git submodule add http://server/path.git folder-name
git submodule update --init
git submodule update --init --recursive
git submodule sync
git submodule update