git-提交并推动本地更改而不会丢失文件差异?

发布于 2025-01-26 19:39:43 字数 428 浏览 3 评论 0原文

我在vscode中,只是对我的分支进行了大量更改。由于没有在线备份,我有一个粗略的草稿,这将是可耻的。因此,自然而然的是,我的更改是很聪明的。

但是这样做将删除我所有的文件差异,即Visual Studio Code的界面在侧边栏中显示我(请参见下图)。有什么方法可以推到远程分支,但仍然可以将更改保持未分布(或将它们带回尚未分布),或者至少保持这些差异文件的任何方法看到我触摸的地方?

I'm in VSCode and just made a ton of changes on my branch. I have a rough draft that would be a shame to lose due to to not backing up online. So naturally it would be smart to git add . my changes, then git push origin myBranch to create a remote backup.

But doing so will remove all my file diffs that Visual Studio Code's interface shows me in the sidebar (see picture below). Is there a way I can push to a remote branch but still keep the changes unstaged (or bring them back to unstaged), or any way to at least keep those diff files so I can still continue work on my local and easily be able to see everywhere that I touched?

7 files changed, clicking here will show all my diffs

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

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

发布评论

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

评论(3

讽刺将军 2025-02-02 19:39:43

您进行提交并将其推动以进行远程备份。

然后,您将其分支在本地丢弃,

git reset HEAD~

您将分支放在上一个提交上,并在文件中留下所有更改,以便您可以看到diffs。

请注意,稍后您必须在完成本地提交后的稍后将您的分支强加。根据如何设置远程存储库,这可能不是问题。

You make a commit and push it to make the remote backup.

Then you discard the commit locally with

git reset HEAD~

This points your branch to the previous commit and leaves all changes in the files so that you can see the diffs.

Be aware that you will have to force-push your branch later on when you have finished your local commits. That may or may not be a problem depending on how your remote repository is set up.

风吹过旳痕迹 2025-02-02 19:39:43

如果您没有任何更改,您会推出什么?

简单的解决方案是。保留您进行更改的所有文件,然后撤消更改。

以后您可以参考复制文件的更改

what will you push if you don't have any changes?

simple solution will be . keep a copy all the files that you have made changes, then undo changes.

later you can refer to the changes from copied files

神妖 2025-02-02 19:39:43

通过使用git stash保存您的工作。推动承诺的更改后,您可以将“无需更改”称为git stash pop。请参阅文档在这里

save your work by using git stash. after pushing committed changes then you can call uncommitted changes as git stash pop. see the documentation here

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