Hacker News new | past | comments | ask | show | jobs | submit login

All the git-rebase-fu I have ever needed while working with pull requests, I have found in this well written guide: https://github.com/susam/gitpr

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



Thank you for sharing this link. Until now, I never understood properly how rebase and fast-forward merges work. This simple note in this document made it all clear.

"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!




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: