如何通过从远程存储库中使用特定版本版本的GIT数据更新我的项目,以便提出新的合并请求?
我已经通过安装ZIP而不克隆安装了gitlab上的远程存储库的特定版本版本,我进行了更改,现在我想对我的更改进行新分支的合并请求。但是我无法创建一个新的分支(本地),我想我需要安装信息或从git跟踪数据并将其添加到文件中,该如何做?
请注意,我没有为此使用命令行,我只是在寻找通用说明。
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
一种实力是要移动您现有的本地文件夹,克隆存储库,并导入您移动的本地文件夹:
请注意,使用和
git分支-Set-upstream my_branch onect/my_branch
,您不必再推开-U
。git push
将足以建立具有Origin/MyBranch
的远程跟踪分支。An altenrative would be to move your existing local folder, clone the repository, and import your moved local folder:
Note that with Git 2.37 (Q3 2022) and a
git branch --set-upstream my_branch origin/my_branch
, you won't have to use-u
on your first push anymore.git push
will be enough to establish a remote tracking branch withorigin/myBranch
.你不能。下载zip文件而不是克隆git存储库是一条死端路径。不要那样做(当然,除非您想在此死胡同停止,但是在这种情况下,您不希望那样)。
您 can 不过从这个错误中恢复。首先拨打GitLab,然后将其克隆到笔记本电脑(或任何本地计算机),即相关的存储库中,将其转移到笔记本电脑上的新位置中,将修改的版本与新的Clone 分开。您现在拥有三个东西:
使用笔记本电脑上的克隆,请查看您用来制作原始ZIP文件的任何分支。请注意,这些步骤都不需要发生在Android Studio内部(我不使用,不能说更多)。
现在,使用命令行(我将在这里假装的提示是一个简单的美元符号
$
),您可以在新的克隆中执行此操作: 1此
git状态
应显示您的更改,因为“提交的更改”。使用git diff-starged
将这些更改作为更改,从命令行更改,或者如果您更喜欢在IDE中工作,则在此克隆中重新启动Android Studio。现在,您可以做出新的提交,使用git push
将新提交发送给您的gitlab叉,然后使用gitlab来合并请求。一旦您完全满足了的git存储库工作,就可以按照您想要的方式来处理,就可以安全地完全删除您制作和编辑的未拉链文件。在此之前,当您开始使用Git时,这是备份。
1 我假设您有一个类似Linux的系统。如果没有,您可能需要调整非GIT命令。
You can't. Downloading a zip file instead of cloning a Git repository is a dead-end path. Don't do that (unless you want to stop at this dead end, of course, but in this case you do not want that).
You can recover from this mistake though. Start by forking on GitLab, and then cloning to your laptop (or whatever local computer), the repository in question, into a new location on your laptop, keeping your modified version separate from the new clone. You now have three things:
Using the clone on your laptop, check out whichever branch it was that you used to make the original zip file. Note that none of these steps need to happen inside Android Studio (which I don't use and cannot say more about).
Now, using the command line (whose prompt I will pretend, here, is a simple dollar sign
$
), you can do this in your new clone:1The result of this
git status
should show your changes as "changes staged for commit". Usegit diff --staged
to view those changes as changes, from the command line, or re-start Android Studio in this clone if you prefer to work in an IDE. You can now make a new commit, usegit push
to send the new commit to your GitLab fork, and use GitLab to make a Merge Request.Once you are fully satisfied that your Git repository work is working the way you would like it to, it is then safe to completely remove the unzipped files you made and edited earlier. Until then, that's acting as a backup while you get yourself started with Git.
1I assume here that you have a Linux-like system. If not, you may need to adapt the non-Git commands.