git - 如何将更改从 master merge 到 git 中的我的分支

标签 git git-merge

我错误地在主分支上工作,
我如何将更改从master转移到我的分支?
谢谢。

最佳答案

您可以从存储库的根目录运行以下命令

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.

注意:#后面的语句是注释。它不属于命令,执行命令时应将其排除。

关于git - 如何将更改从 master merge 到 git 中的我的分支,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55156080/

相关文章:

git - 将更改从 master merge 到我的分支

git - 克隆企业 git 存储库

git 忽略 .env 文件不起作用

ruby-on-rails - 在 Windows 中开发 Ruby 和 Rails?或 Linux 虚拟机

git - 如何检查 git merge 问题是否已修复?

git - 在 github 上的 fork 中跟踪上游的最佳实践

git - 当我推送到一个有效的 SSH 地址时,为什么 git 无法解析主机名?

验证连接时 git 权限被拒绝(公钥)

混帐/Github : Commit got lost

Git mergetool 性能