by limxto0 · 7y ago · 0 comments
Quoting from this document below.
# Rebase topic branch on the main development branch (optional).
git checkout TOPIC-BRANCH
git rebase master
# Edit commits, e.g., last 3 commits in topic branch (optional).
git checkout TOPIC-BRANCH
git rebase -i HEAD~3
# Force push rebased/edited commits to the pull request (optional).
git push -f origin TOPIC-BRANCH"Beginners to this workflow should always remember that a Git branch is not a container of commits, but rather a lightweight moving pointer that points to a commit in the commit history.
A---B---C
↑
(master)
When a new commit is made in a branch, its branch pointer simply moves
to point to the last commit in the branch. A---B---C---D
↑
(master)
A branch is merely a pointer to the tip of a series of commits. With
this little thing in mind, seemingly complex operations like rebase and
fast-forward merges become easy to understand and use."Suddenly everything makes sense now!