How to take latest changes from dev branch to my current branch
These are the steps that I do for that, though using command line interface.
- Checkout dev branch (git checkout dev)
- Get the latest of dev branch (git pull)
- Checkout branch B (git checkout B)
- Merge dev branch to branch B (git merge dev)
You can follow these steps using your github desktop.
It's a good practice to as soon as feasible after person A pushes the changes to dev
for person B to get these changes into their branch b
. This is so that person B works on latest code and their eventual merge to dev
is easy.
Option 1, pull
- Commit all changes to branch
feature_branch
(git status showsclean
) git checkout dev
git pull
- this fetches (downloads) the changes onto computerb
and merges these changes into the currently checked out local branch on computerb
(in this case branchdev
). This operation should normally be a 'fast-forward' (so no merge conflicts)git checkout feature_branch
git merge dev
- this merges changes fromb
's localdev
to thefeature_branch
.git mergetool
- resolve conflictsgit commit
- commit your merge
With this option b
's both local dev
and feature_branch
have latest changes.
Option 2, fetch
- Commit all changes to branch
feature_branch
(git status showsclean
) git fetch origin dev
- this downloads latest changes todev
, but doesn't merge them to localdev
git merge origin/dev
- this merges changes from the downloaded version ofdev
to thefeature_branch
.
In this scenario b
's local feature_branch
will have the most recent changes from dev
as they are on the remote repo and their local dev
will not have these changes. This is OK, since b
isn't working on dev
, (s)he's working on feature_branch
.
I like option 2 as I don't need to checkout dev
, but both options are equally correct.