git GitHub - 不同步提交?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/8174324/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 06:10:49  来源:igfitidea点击:

GitHub - Unsynchronized Commit?

gitgithub

提问by rg88

I made a bunch of changes to files in a git repository. Before I committed anything I was asked to commit some other files someone else had for me (coming from an SVN repository). I dropped those files into my project folder, picked them from amongst all of the changed files from earlier and committed them. Now I need to Sync the branch to get these to move to Github but when I try to sync I get "Uncommitted Changes. Please commit your changes before syncing".

我对 git 存储库中的文件进行了大量更改。在我提交任何内容之前,我被要求提交其他人为我准备的其他文件(来自 SVN 存储库)。我将这些文件放入我的项目文件夹中,从之前所有更改过的文件中挑选它们并提交。现在我需要同步分支以使这些分支移动到 Github,但是当我尝试同步时,我得到“未提交的更改。请在同步之前提交您的更改”。

I assume this refers to all of the files I had changed previously? However, I do not want those so be committed... they are not ready. I only want to commit this small subset of files. What does one do in this situation? How do I move all of the changes I've made that I do NOT want to be a part of this commit out of the way, for lack of a better word, and get the part I DO want to change into the github repository?

我认为这是指我之前更改过的所有文件?但是,我不希望那些人如此投入……他们还没有准备好。我只想提交这个小文件子集。在这种情况下怎么办?我如何移动我所做的所有更改,我不想成为此提交的一部分,因为缺少更好的词,并将我想要更改的部分放入 github 存储库?

I'm using the GitHub App but can do it from the command line if needed... just not sure what needs to be done.

我正在使用 GitHub 应用程序,但如果需要,可以从命令行执行此操作……只是不确定需要做什么。



Here are some screenshots to make it clearer:

以下是一些屏幕截图,以使其更清晰:

At the bottom of my list of changed files is the commit I want to move:

在我已更改文件列表的底部是我要移动的提交:

enter image description here

在此处输入图片说明

Trying to get that commit to move over to github I click the Sync button and get:

试图让提交转移到 github 我点击同步按钮并得到:

enter image description here

在此处输入图片说明

What is the solution? How do I get these "uncommitted changes" out of the way? Obviously I am new to git so I am not clear on the correct approach. Thanks.

解决办法是什么?我如何摆脱这些“未提交的更改”?显然我是 git 新手,所以我不清楚正确的方法。谢谢。

回答by Lily Ballard

I don't know if the GitHub app provides this functionality (though I would kind of expect it to), but git has a function called "git stash" which takes all your uncommitted changes and stashes them away in a special place. This leaves you with a pristine working copy (without those changes), where you can do whatever you need to, and then use git stash pop(or git stash apply) to reapply your uncommitted changes. I encourage you to read the manpage.

我不知道 GitHub 应用程序是否提供了这个功能(虽然我有点期待它),但是 git 有一个名为“git stash”的函数,它可以获取所有未提交的更改并将它们存放在一个特殊的地方。这为您留下了原始的工作副本(没有那些更改),您可以在其中执行任何您需要的操作,然后使用git stash pop(或git stash apply) 重新应用您未提交的更改。我鼓励您阅读联机帮助页

回答by Mike Roberts

In the GitHub for MacGUI client, go to Repository> Pushon the menubar.

GitHub for MacGUI 客户端中,转到菜单栏上的存储库>推送

This will upload any unsynced commits to the GitHub server. Since this does not download any new code, the GitHub client will not force you to commit all your changes. This is useful if you have a bunch of local changes that are not ready to commit, but you also have several local changes that are ready to commit.

这会将任何未同步的提交上传到 GitHub 服务器。由于这不会下载任何新代码,因此 GitHub 客户端不会强制您提交所有更改。如果您有一堆尚未准备好提交的本地更改,但您还有几个准备好提交的本地更改,这将非常有用。

This seems easier than (although conceptually equivalent to) the previous suggested answers involving the git command-line interface.

这似乎比(尽管在概念上等同于)先前涉及 git 命令行界面的建议答案更容易。

回答by aLearner

Thought the following discussion

想到以下讨论

Committing Files Back to GitHub for Windows

将文件提交回 GitHub for Windows

may help readers of this question.

可能对这个问题的读者有所帮助。