I've been following this guide for working with distributed git projects: http://nvie.com/posts/a-successful-git-branching-model/. It has worked well but now I have run into a snag. I have created a local feature branch. I would like to keep this feature branch up-to-date with the latest changes made in dev
. Is this possible? I was researching this and found I would probably need to use rebase
. But there were so many options I didn't know exactly which one I needed to use. How would I do this?
Merge the changes from origin/master into your local master branch. This brings your master branch in sync with the remote repository, without losing your local changes. If your local branch didn't have any unique commits, Git will instead perform a "fast-forward".
Might be good to recommend an initial "git checkout master; git pull" to ensure that the local master branch is up-to-date.
Periodically:
λ git checkout dev
λ git pull origin dev
λ git checkout myfeaturebranch
λ git merge dev
Running git rebase dev
while on the feature branch should do the trick (update local dev from origin first, if necessary).
That will replay your changes from the feature branch onto dev, then sets the feature head to be the head of the new history.
Note: Only rebase
if your feature branch commits have not yet been pushed. It will rewrite your history. There are some caveats with rebase
which may or may not be worth the risk.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With