git checkout source-branch
git branch -f target-branch
git push origin target-branch --force
git branch -d branch_name
(--delete)
git branch -D branch_name
(--delete --force)
Delete the most recent commit, keeping the work you've done:
git reset --soft HEAD~1
Delete the most recent commit, destroying the work you've done:
git reset --hard HEAD~1
Then Push force
git push origin branch_name --force
Rebase before push:
git stash save -> if you have changes in your branch
git checkout branch_to_rebase
git pull
git checkout old_branch
git rebase branch_to_rebase
git push -f
git stash pop
Rebase after commit and push:
git checkout branch_to_rebase
git pull
git checkout old_branch
git rebase -i branch_to_rebase
git push -f
Rebase to organize
git rebase --autosquash --interactive main
git branch -a
(Local and Remote)
git branch -r
(Remote)
git fetch --all
git pull -- all
git fetch --prune
git verify-pack -v .git/objects/pack/pack_name.idx \
| sort -k 3 -n \
| tail -10
To see what each file is, run this:
git rev-list --objects --all | grep [first few chars of the sha1 from previous output]
One option is to use the bfg-repo-cleaner tool. Alternatively, you could do it manually following this git article, as outlined below:
git filter-branch --index-filter 'git rm --cached --ignore-unmatch *.mov' -- --all
rm -Rf .git/refs/original
rm -Rf .git/logs/
git gc --aggressive --prune=now
Then repeat with other types of files.
Then verify:
git count-objects -v
Your size-pack should be a lot smaller now.