-
Notifications
You must be signed in to change notification settings - Fork 1
How to pull and merge 'development' into your working branch
Since we are all working in parallel, it will often happen that changes are added to development
on GitHub while you are busy working locally.
It is good practice to pull the latest version of development
and merge it with your working branch before doing a PR. Here's how to do it.
git checkout development
git pull origin development
This is necessary because merge always happens in the current branch.
git checkout <branch>
git merge development
In case of conflict git
tells you that the automatic merging failed and where the conflicts are.
git status
The files that can be merged are staged. The unstaged files are the ones you need to edit and/or remove.
Open the file in your favourite editor. The areas you need to edit are marked like this (example from merging package.json
on the client):
<<<<<<< HEAD
"proxy": "http://localhost:3001"
}
||||||| merged common ancestors
"proxy": "http://localhost:3001"
}
=======
"proxy": "http://localhost:3001",
"devDependencies": {
"enzyme": "^3.3.0",
"enzyme-adapter-react-16": "^1.1.1"
}
}
>>>>>>> development
The code between <<<<<<< HEAD
and ||||||| merged common ancestors
comes from your working branch.
Between ||||||| merged common ancestors
and =======
is the code in the commit that is the common ancestor of the two branches (normally the version of development
that you created your branch from).
Between =======
and >>>>>>> development
is code coming from the development
branch.
There can be several areas of this type in a single file. You can easily find them by doing a find of HEAD
or <<<<
Your job is to compare the three versions of the code and decide what to keep. When you are done, the file should contain the final merged code with none of the merge markers.
If package.json
has changed in either the server or the client it is imperative to run npm install
again to update the node modules before running any of the programs.
Make sure the test runner runs all the tests by pressing ‘a' in the test window.
Run the app as a whole and make sure it is doing what you expect.
When all the files are merged and tested, you conclude the merge by staging the files and committing.
git add <files>
Note that you need to tell git to remove deleted files from the repo explicitly with:
git rm <file>
Finally commit with a clear message:
git commit -m “Merge with development"