简体   繁体   English

如何在git中将更改从master合并到我的分支

[英]How to merge changes from master to my branch in git

I mistakenly worked on master branch, 我错误地在master分支上工作,
How can i move my changes to my branch from master? 如何将更改从主服务器移到我的分支?
Thanks. 谢谢。

You can run the following commands from the root directory of your repository 您可以从存储库的根目录运行以下命令

git reset HEAD -- .                       #this will unstage all the files
git stash                                 #this will stash all the changes
git checkout <your_branch>                #this will switch the branch
git stash pop                             #this will apply all the stashed changes in <your_branch>.
#If there are conflicts at this point, resolve them, then do the following
git add -all
git commit -am "<your_commit_message>"    #this will commit in new branch.

Note: statement after # is a comment. 注意: #后面的语句是注释。 It doesn't belong to the command & should be excluded when executing the command. 它不属于命令,在执行命令时应排除在外。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在没有更改的情况下将分支合并到git中的master分支中? - How to merge the branch with no changes into master branch in git? git合并到master中,从分支中删除更改 - git merge into master removing changes from branch 在Git中,如何使我当前的分支master或将其合并为master但强制它接受我的所有更改 - In Git how do make my current branch master or merge it to master but force it to accept all my changes 将更改从 master 合并到我的分支的脚本 - Script that will merge changes from the master to my branch git merge master 不将 master 的更改/冲突合并到本地分支 - git merge master not merging changes/conflicts from master into local branch git将分支合并到master而不更改父分支 - git merge branch into master without the changes from parent branch 如何在一个git commit中将master分支的更改合并到我的side project分支中? - How do I merge a master branch's changes into my side project branch in one git commit? 自分支首次创建以来,如何保持Git中的合并不会覆盖我所有主服务器的更改? - How do I keep merge in Git from overwriting all my master's changes since the branch was first created? 如何保护git中的主分支免受合并 - How to protect master branch in git from merge 如何在具有未提交更改的git分支中与master合并 - How to merge with master in a git branch that has uncommitted changes
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM