Git 拉入 IntelliJ 而不修改更改列表

问题描述 投票:0回答:1

我在 IntelliJ 中有多个 git 更改列表,现在我需要通过从远程执行 git pull 来更新我的本地代码。但是,我在执行 git pull 时收到错误,提示“在拉取之前提交/存储”。我可以存储本地代码然后拉取,但每当我存储代码时,我的更改列表就会合并。现在我需要找到一种方法来克服这个问题。我怎样才能在 IntelliJ 中做到这一点?

队友将他们的代码推送到远程,现在我需要在本地设置中使用该代码。
我无法提交我的,因为它还没有完全开发,我也无法隐藏,更改列表将被合并。

有没有一种方法可以在不提交或存储的情况下进行拉取?或寻找更好的解决方案。

git git-pull git-remote
1个回答
0
投票

我无法提交我的,因为它还没有完全开发

是的,你可以而且应该!

您应该停止使用 git stash,而只是像正常的普通提交一样签入更改 - 尽管将它们标记为临时提交

TL;博士

git stash push
替换为
git commit -am "==== temp ===="
git stash pop
git reset HEAD^ # On the same branch as you did the temp commit above!


因此,假设您正在处理的分支名为

my_feature_branch
并且您当前正在进行一些更改:

git switch my_feature_branch
git status
git add $...WHATEVER_FILES_ARE_MODIFIED...
git commit -m "==== before pull of teammate's changes ===="
git fetch origin
gitk --all &     # Optional, but lets you inspect what the difference between your
                 # my_feature_branch branch and the new changes from
                 # origin/my_feature_branch.
git rebase origin/my_feature_branch my_feature_branch
# If any conflicts, use https://github.com/hlovdal/git-resolve-conflict-using-kdiff3
git reset HEAD^ # Undo the earlier temporary commit, bringing you back to where you were,
                # but now on top of the newly fetched changes from your teammate.

临时签入东西然后稍后更改/删除不仅可以,如果不这样做,你就没有正确使用 git。 git 初学者有时害怕检查事物,但这是错误的心态 - 你应该害怕不检查更改

(而且可能比现在更频繁,办理入住和回家的时间永远不应该超过 2 分钟)。

© www.soinside.com 2019 - 2024. All rights reserved.