如何区分需要在git中提取的文件,以及在本地提交并准备推送的文件

发布于 2025-02-12 03:41:45 字数 882 浏览 3 评论 0原文

我如何确定我本地存储库中的哪些文件已投入并准备好被推开,并且一旦您已经完成了“ git fet fetch”,其他人已被其他人推出并且需要被拉出?

例如:

git fetch
...

$ git diff --stat --staged origin/Release_Candidate

 AP4Configuration/ChangeLog.txt    | 3 +--
 AP4Configuration/appsettings.json | 3 +--
 Local5.txt                        | 1 -
 3 files changed, 2 insertions(+), 5 deletions(-)

我上演并承诺 appsettings.json and local.txt ,他们准备将其作为本地提交的一部分推送,但是 changelog .txt 需要从服务器上的存储库中提取。

我该如何分辨 changelog.txt 在需要拉的服务器上,以及 appSettings.json local.txt 是否来自我本地机器上需要推动的提交?

我从以下情况下得到相同的结果:

git diff --stat --cached origin/Release_Candiate
git diff --stat --HEAD origin/Release_Candiate

有什么办法可以确定需要拉出哪些文件,哪些文件可以推动?

例如,我希望看到将要推开的本地提交中的文件,而不会看到服务器上最新提交中的文件,该文件已准备就绪。

我正在为工作场所更新GUI GIT界面,用户需要查看此信息。谢谢。

How do I determine which files in my local repository are committed and ready to be pushed, and which files have been pushed by someone else in the meantime and need to be pulled, once you've already done a 'git fetch'?

For example:

git fetch
...

$ git diff --stat --staged origin/Release_Candidate

 AP4Configuration/ChangeLog.txt    | 3 +--
 AP4Configuration/appsettings.json | 3 +--
 Local5.txt                        | 1 -
 3 files changed, 2 insertions(+), 5 deletions(-)

I staged and committed appsettings.json and local5.txt and they are ready to be pushed as part of the local commit(s), but Changelog.txt needs to be pulled from the repository on the server.

How can I tell that Changelog.txt is in a commit on the server that needs to be pulled, and appsettings.json and local5.txt are from a commit on my local machine that needs to be pushed?

I get the same result from:

git diff --stat --cached origin/Release_Candiate
git diff --stat --HEAD origin/Release_Candiate

Is there any way I can determine which files need to be pulled, and which ones are ready to push?

For example, I would like to see the files in the local commit(s) that will be pushed, without seeing the ones that are in the latest commit on the server ready to be pulled.

I am updating a GUI Git interface for my workplace, and the users need to see this information. Thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

羅雙樹 2025-02-19 03:41:45

除非您完成了git fetch(直接或通过git lupl),否则您本地存储库中没有其他人推动的更改。这些文件位于远程存储库中。

当您使用git提取获取上游更改时,远程分支将更新为最新的提交。

您的本地更改是在跟踪远程分支的 local 分支上,因此您在该分支上看不到这些更改。

例如,如果远程存储库称为Origin,并且分支为Master,则远程分支为onect> Origin/Master>主是指本地分支。

您可以使用git日志和其他工具检查远程更改。例如,如果远程分支被称为Origin/Master,则可以git log oint/master列出您在git fet fet 。

要结合两者,您必须rebaseMERGE

git rebase下,您所承诺的所有本地更改首先将其存放在某个地方,然后您的分支被更新以匹配远程分支。然后,您的更改将樱桃挑选回您当地的分支。自动合并发生,但是可能会出现您必须手动修复的冲突。有一个工作流程,重新构想停止,使您遭受了所有挑剔的更改的情况,除了冲突文件外,您必须进行编辑以删除冲突标记,然后使用添加到舞台上。 git add;然后git rebase - continue

除非基于当前远程分支(即具有远程分支作为祖先的当前提交),否则您的本地分支不能将其推向远程存储库(至少没有- 强制)。为了推动您的变化,您会有提取,重新弹力和推动。如果推动被拒绝是因为其他人在重新审视时推了一些新东西,则必须重复获取,反弹和推动。

There are no changes in your local repository that have been pushed by someone else unless you have done a git fetch (directly or via git pull). Those files are in a remote repository.

When you fetch the upstream changes with git fetch, the remote branch is updated to the most recent commit.

Your local changes are on the local branch which tracks the remote branch, and therefore you don't see those changes on this branch.

For instance, if the remote repository is called origin and the branch is master, then the remote branch is origin/master, and master refers to the local branch.

You can inspect the remote changes with git log and other tools. E.g. if the remote branch is called origin/master, you can git log origin/master to list the new changes you've picked up after git fetch.

To combine the two, you must either rebase or merge.

Under git rebase, all your local changes that you have committed are first stowed away somewhere, and then your branch is updated to match remote branch. Your changes are then cherry-picked back into your local branch, one by one. Automatic merging takes place, but conflicts may arise that you have to manually repair; there is a workflow for that whereby the rebase stops, leaving you with a situation where all the cherry-picked changes are staged, except for the conflicted files, which you must edit to remove conflict markers and then add to the stage with git add; then git rebase --continue.

Your local branch cannot be pushed (at least not without --force) to the remote repository unless it is based on the current remote branch (i.e. has the current commit of the remote branch as an ancestor). To push your change you have fetch, rebase and push. If the push is rejected because someone else pushed something new while you were rebasing, you must repeat fetch, rebase and push.

土豪我们做朋友吧 2025-02-19 03:41:45

我终于弄清楚了我需要做什么。

在“ git提取”之后,以下命令同时显示本地和远程更改:

$ git diff --stat --cached origin/Release_Candidate

 AP4Configuration/ChangeLog.txt    | 3 ++-
 AP4Configuration/appsettings.json | 3 ++-
 Local5.txt                        | 1 +
 3 files changed, 5 insertions(+), 2 deletions(-)

但是要查看我自己修改的文件,并且将作为我本地提交的一部分推动:

$ git diff --stat --merge-base origin/Release_Candidate

 AP4Configuration/appsettings.json | 3 ++-
 Local5.txt                        | 1 +
 2 files changed, 3 insertions(+), 1 deletion(-)

此列表不显示ChangElog.txt 。现在,它仅显示我本地提交的文件。因此,我可以看到将推出提交中的哪些文件,哪些文件需要从服务器端提交中提取。

I've finally figured out what I need to do.

After a 'git fetch', the following command shows both local and remote changes:

$ git diff --stat --cached origin/Release_Candidate

 AP4Configuration/ChangeLog.txt    | 3 ++-
 AP4Configuration/appsettings.json | 3 ++-
 Local5.txt                        | 1 +
 3 files changed, 5 insertions(+), 2 deletions(-)

But to see the file(s) that I myself modified, and that will be pushed as part of my local commits:

$ git diff --stat --merge-base origin/Release_Candidate

 AP4Configuration/appsettings.json | 3 ++-
 Local5.txt                        | 1 +
 2 files changed, 3 insertions(+), 1 deletion(-)

This list does not show Changelog.txt. It now only shows the files I committed locally. Therefore I can see which files in the commits will be pushed, and which ones will need pulling from the server-side commits.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文