How do I create an empty commit?
git commit --allow-empty -m "COMMIT MESSAGE"
How do I work with subtrees?
# Add a subtree.
git subtree add --prefix path/in/your/repo REMOTE_URL BRANCH --squash
# Pull a subtree.
git subtree pull --prefix path/in/your/repo REMOTE_URL BRANCH --squash
# Push a subtree.
git subtree push --prefix path/in/your/repo REMOTE_URL BRANCH
How do I checkout files from another branch?
git checkout BRANCH -- FILE_PATH
What is forking in Git?
- Forking is done on the Git server.
- A fork is a remote copy of a repository.
- It is commonly used in Open Source development.
- The original remote repository can be added as the
upstream
remote to the local fork. - Atlassian: Forking Workflow
How can I change a commit author?
git rebase -i -p COMMIT_HASH
# Mark the commit you want to change with `edit`.
git commit --amend --author="John Doe <john.doe@example.com>" --no-edit
git rebase --continue
- Use interactive rebase to edit the commit.
- Mark the commit you want to change as
edit
. - You will be recoreded as the commiter of the commit.
- Tower: How can I change the author name / email of a commit?
How do I squash all commits?
Run git rebase --root -i
and change pick
to squash
for all commits except the first one.