简体   繁体   中英

How to push changes from one branch to another?

I am working on a local git repository. There are two branches, master and development . I want to push development changes to master branch, how do I do that? When I do:

 git branch -a

I see...

* development
  master
  remotes/origin/HEAD -> origin/master
  remotes/origin/development
  remotes/origin/master

Make sure first you update your development branch with master to resolve conflicts issue(if there are any):

git checkout master
git pull origin master
git checkout development
git merge master

Now see if master branch is merged without any conflict, if there's any conflict then you'll have to resolve them. Once you're done with that, you can:

git checkout master
git merge development
git push origin master

You want to be on the master branch then merge the development branch into it. If there are conflicts it will fail and tell you where they are.

git checkout master
git merge development

I tend to be over cautious and do everything in a local, disposable, repository then push it back upstream after everything is sorted/merged.

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM