Skip to content
This repository was archived by the owner on May 29, 2022. It is now read-only.

How to Edit Feature Branches

Bryan Masamitsu Parsons edited this page Sep 25, 2018 · 1 revision

HOWTO Edit Feature Branches

This assumes that you are working with an existing feature branch that has already been pushed to the Github GPSTk repo, and for which you have a local tracking branch.

Simple Recipe:

  1. Fetch all feature branch updates: git fetch --all
  2. Pull updates from the remote server into your local tracking branch: git merge origin/issue_99 issue_99
  3. Checkout the feature branch: git checkout issue_99
  4. Make changes: echo "Hello World" > README.txt
  5. Add changes: git add README.txt
  6. Commit changes: git commit -m "Did stuff that fixes issue_99"
  7. Update master branch: git checkout master; git pull
  8. Merge updates from master into feature branch: git merge master issue_99
  9. Push feature branch updates to remote server: git push origin issue_99

Detailed Recipe:

  1. Fetch all updates to the feature branch
    • git fetch --all
    • Alternatively, if you really want to only fetch a single feature branch
      • git fetch origin issue_99:refs/remotes/origin/issue_99
  2. If another developer is actively working on the feature branch, you may need to pull updates to the feature branch before merging with master:
    • git checkout issue_99
    • git merge origin/issue_99 issue_99
  3. Once you are sure the feature branch is up to date, make changes to the branch and commit them
    • git checkout issue_99
    • git commit -m "Did stuff that fixes issue_99"
  4. Once you're ready to prepare for merging with master, pull the latest updates to master branch, and merge onto the feature branch, resolving any resulting merge conflicts
    • git checkout master
    • git pull origin master
    • git checkout issue_99
    • git merge master issue_99
    • This last step adds a new commit object on the end of feature branch issue_99 without changing the master branch. The order of the branch names is important!
  5. What about using git rebase instead of git merge?
    • It is far too easy to screw things up if you rebase on a "public" branch, i.e. one visible to others
    • Please follow the "Golden Rule of Rebasing": never rebase a branch that you've already pushed
  6. Push the updated feature branch to the remote on the Github GPSTk repo:
    • git push origin issue_99

Clone this wiki locally