git add -p <filename>
git remote add upstream <upstream git url>
##Undo a commit
git reset --soft HEAD^
git fetch upstream
git checkout <branch>
# the following will create a merge commit
git merge upstream/master --no-ff
# rebase
git rebase upstream/master
git pull --rebase -s recursive -X ours
git checkout master
git checkout -b <branch_name>
add some commits then push
push -u origin <branch_name>
git remote add other /path/to/XXX
git fetch other
git checkout -b ZZZ other/master
mkdir ZZZ
git mv stuff ZZZ/stuff # as necessary
git commit -m "Moved stuff to ZZZ"
git checkout master
git merge ZZZ # should add ZZZ/ to master
git commit
git remote rm other
git branch -d ZZZ # to get rid of the extra branch before pushing
git push # if you have a remote, that is
git branch placeholder
git checkout -b placeholder
git branch -D master
- On github change default branch to
placeholder
and delete themaster
branch - Delete the repo and reclone it ? Not sure if this step is necessary
git checkout -b master
git push origin master
- Change default branch on github to
master
again
git branch -D placeholder
git tag -a 1.2.3 -m 'version 1.2.3'
git push --tags
git grep <regexp>
git log -G <regexp>
git revert <sha>
This will create a new commit with a diff reversing the commit referred by