I don't think I'm even asking this right. Here is my situation.
I have a local repository with master
and dev
branches. Same thing on Github.
Another developer created a branch and pushed it to the Github, and then created a pull request. I merged this pull request into master
on Github.
Locally, I did a git pull
and my local master
updated. However, now my dev
branches on both local and Github don't have the change from that pull request.
I would like to make dev
start all over from master
. I basically spend 95% of my time in this dev
branch and if I want to fire up a Rails console locally I want it to work as expected.
How do I do this (and what's it called)?
They are separate branches from Master, thus why they don't have the changes on Master.
Typically what you would do is now merge your master branch in with your dev branch. There could be merge conflicts that you will have to resolve.
I am assuming that you want to keep your changes in dev but just add the stuff in master until you are ready to also push to master.
If you
git checkout dev
git merge master
Here is the basic branching and merging tutorial https://git-scm.com/book/en/v2/Git-Branching-Basic-Branching-and-Merging
And here is one from atlassian https://www.atlassian.com/git/tutorials/using-branches/git-merge
Keep in mind that Git versioning only goes forward. Once you approve a PR to master
, then master
is at the latest point in the flow. If you want to incororpate these changes into dev
, all you need to do is swap to the dev
branch and then merge
master
into it:
git checkout dev
git merge master
Pulling the changes from master
to dev
is common practice after a release. However, in theory, there should never be any changes in master
that don't exist in dev
, as both hotfix
branches and release
branches should be merged into dev
directly.
Feature branches in themselves should only go out to dev
, with dev
ultimately carrying those feature branch changes to master
through means of a release
branch.
Urgent changes can indeed be planned for master
, though these should be created as a hotfix
branch which gets merged into both dev
and master
.
This follows the process know as Git Flow , which has the following illustrated flow from top-to-bottom (and I would strongly recommend following):
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.