运行 git 命令时出现此错误 git pull origin master 到 my server repository.
please, commit your changes or stash them before you can merge. aborting in
run of pull command
我在运行这个程序时遇到了很多次。为了解决这个问题,我尝试了git reset --hard。但是还有其他解决方案。
实际上问题是我在 pull 之前做了一些更改,现在 master 在我工作的同一个文件中做了一些更改。所以我确实想推动当前的变化并接受来自主分支或其他分支的新变化。
我的经验是,当错误或冲突发生时,遵循 Git 客户端指令。
在合并之前提交您的更改或存储它们。
因此,
(1)
git stash
(2) 合并
(3)
git stash pop
是的 git
git stash
是一个选项,但有时我们必须保留当前更改,然后我们可以做一件事,我们可以从当前分支创建新的临时分支,然后隐藏旧分支。所以通过这种方式我们可以将当前代码复制到临时分支并接受来自新分支的新提交。
为此我们必须创建新的分支。
git checkout -b <temporary_branch_name>
git merge <current_branch> // optional. because git checkout automatally do it.
git checkout <old branch name > // come back on disputed branch
git stash // remove current changes.
git pull origin <branch_name> // for accept new changes.