git add -N . && git add -p "./*foo*"
git add -N . && git add -p
git log --follow -- <filename>
git fetch <remote> <rbranch>:<lbranch>
git checkout <lbranch>
git checkout stash@{0} -- <filename>
git diff stash@{0}^1 stash@{0} -- <filename>
git checkout <commit> <path/to/file.ext>
(Don't do it with public commits, only for local. It rewrites history.)
- Do a new commit fixing the old commit.
- Rebase until a previous commit in history.
git rebase -i <commit>
- In the text editor, move the new commit just under the want you want to modify and change
pick
forsquash
. For moving lines in vim usedd
to cut the line andp
to paste it.
git diff --no-index <path/to/file1.json> <file2.json>
git stash push -- <path/to/directory>
cd </path/to/my/repo>
git remote add origin ssh://git@bitbucket.org/<username>/<reponame>.git
git push -u origin --all
To squash the latest 3 commits:
git rebase @~3 -i
In vim pick
the last one and change all others to s
:2,20s/pick/s/g
git push origin <local-name>:<remote-name>
Test it first:
- Change master by the name of the branch you want to keep, the branches showing will be eliminated
git branch | grep -v "master"
- Eliminate branches with xargs
git branch | grep -v "master" | xargs git branch -D