Powerful but confusing.
git archive --format=tar --prefix=foo_bar-1.0/ v1.0 | xz > foo_bar-1.1.tar.xz
git checkout --orphan $TEMP_BRANCH
git add -A
git commit -am "Initial commit"
git branch -D master
git branch -m master
git push --force origin master
git push origin --delete the_remote_branch
git push origin :the_remote_branch
git commit --amend --author="John Doe <[email protected]>"
This uses interactive rebase.
# Identify the commit before the one you want to change and start rebase.
git rebase -i -p 8294ad8
# In the editor window that opens, identify all commits you want to change and
change "pick" to "edit".
# Change author name
git commit --amend --author="John Doe <[email protected]>" --no-edit
# Continue rebase
git rebase --continue
Change OLD_EMAIL
, CORRECT_NAME
and CORRECT_EMAIL
to desired values, afterwards run git push --force --tags origin 'refs/heads/*'
.
git filter-branch --env-filter '
OLD_EMAIL="[email protected]"
CORRECT_NAME="Your Correct Name"
CORRECT_EMAIL="[email protected]"
if [ "$GIT_COMMITTER_EMAIL" = "$OLD_EMAIL" ]
then
export GIT_COMMITTER_NAME="$CORRECT_NAME"
export GIT_COMMITTER_EMAIL="$CORRECT_EMAIL"
fi
if [ "$GIT_AUTHOR_EMAIL" = "$OLD_EMAIL" ]
then
export GIT_AUTHOR_NAME="$CORRECT_NAME"
export GIT_AUTHOR_EMAIL="$CORRECT_EMAIL"
fi
' --tag-name-filter cat -- --branches --tags
git add --patch /path/to/file
git submodule update --recursive --remote
git tag v1.0
git push origin v1.0
git checkout squashed_feature
git rebase -i development
Squash all commits but the first.
pick fda59df commit 1
squash x536897 commit 2
squash c01a668 commit 3
Write a proper commit message, probably with a Jira ticket number or the like.
Checkout development branch and merge squashed feature branch.
git checkout development
git merge squashed_feature
Newer Git allows you to do the squash merge in one step if you use feature branches:
git merge --squash squashed_feature
You can do it without the --
, but if the filename looks like a branch or tag
(or other revision identifier), it may get confused, so using -- is best.
git checkout -- file
(Source)
git config --global commit.verbose true