如果更改了本地文件但在添加新文件之前该怎么办?(What to do if changed local files but before you could push a new file was a

编程入门 行业动态 更新时间:2024-10-28 17:14:31
如果更改了本地文件但在添加新文件之前该怎么办?(What to do if changed local files but before you could push a new file was added?)

我问过另一个问题,但意识到我错过了陈述,所以删除了它。 你如何用Git解决以下问题? 你有一个回购。 您克隆了repo并对源代码进行了一些更改。 在推送之前,您使用Github.com添加新文件(例如,您创建自述文件)。 如果您尝试推送,我认为您有合并冲突,但由于文件本身不包含冲突,因此修复似乎微不足道。 你是如何解决这个问题的?

我过去遇到过麻烦,我开始在本地工作,然后去制作一个repo并用自述文件(本地副本没有)初始化它并且出错了。

TL; DR我问如果本地仓库中有不同的文件(或者还没有初始化repo)和远程仓库会发生什么,但是各个文件不冲突。

I had asked another question but realized I miss-stated so deleted it. How do you resolve the following situation with Git? You have a repo. You clone the repo and make some changes to the source code. Before pushing, you use Github.com to add a new file (for example you create a readme file). I think you have a merge conflict if you try to push, but it seems trivial to fix since the files themselves don't contain conflicts. How do you resolve this?

I've had trouble in the past where I started working locally and went to make a repo and initialized it with a readme file (that the local copy didn't have) and got errors.

TL;DR I'm asking what happens if there are different files in the local repo (or the repo hasn't been initialized) and the remote repo, but the individual files don't conflict.

最满意答案

如果单个文件不冲突并且您尝试从本地存储库推送到同一分支上的远程存储库,则不会发生合并冲突。

最有可能的是,在推送您的更改之前,系统会提示您进行git pull 。 Git会认识到它们没有冲突的信息,当你运行git push时,本地存储库中的添加内容将被添加到远程存储库中。

没有必要改变或隐藏任何东西。

If the individual files don't conflict and you try to push from the local repository to the remote repository on the same branch, there will not be a merge conflict.

Most likely, you will be prompted to git pull before pushing your changes. Git will recognize they do not have conflicting information, and the additions on the local repository will be added to the remote repository when you run git push.

There's no need to rebase or stash anything.

更多推荐

本文发布于:2023-08-07 03:02:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1461161.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:但在   改了   新文件   本地文件   changed

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!