简体   繁体   中英

Is it possible to create a branch from my master branch, but merge in other branches, but only commit what is changed from this new branch?

I'm new to Git, learnt a lot so far, but can't seem to figure out how I would do this.

Maybe there is a better way?

I have 4 branches from my master branch. Each one has one fix that does not conflict. I want to create a new branch from my master, fix another bug, that does not conflict with the others, but I want to have these other bug fixes merged in so the bugs aren't present when trying out the code. I cannot merge these branches to the master yet. When I commit to the remote I only want the changes I've made on this branch committed.

Is there an easier way to do this in the future? I need to fix or implement things, each thing one in a different branch, but I want to have a copy that is up to date with all my fixes that isn't merged to the master yet.

Sometimes there is a blantant UI thing that although does not relate to what I'm fixing, I would really like to be fixed while working on something else before I can merge that fix to the master.

I guess you are looking for an octopus merge. Create new branch from master ( by running git checkout -b whatever_name_you_want_for_your_branch master and then just go git merge branch1 branch2 branch3 branch4 . If there are no conflicts that is it.

You always commit changes to the branch you are currently on and it's always local. You don't commit to the remote - you push. When you want to push your branch just go git push remote_name branch_name (don't push it if you want it to have it only locally). And remember that depending on your git configuration git push or git push remote_name may push all your local branches so it is a good habit to specify the branch_name you want to push after the remote_name

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