[英]How to get new files on a GitHub master repo
I'm currently in a course where the professor intermittently releases assignments on a public repo.我目前正在上一门课程,教授间歇性地发布公共存储库上的作业。 I have this repo cloned on my computer, but I don't know how to go about getting the newly released assignments.
我在我的电脑上克隆了这个 repo,但我不知道如何获取新发布的任务。
Essentially, I want to pull the new files without deleting my work on the old files which I have edited.本质上,我想提取新文件而不删除我对已编辑的旧文件所做的工作。 Do I create a fork?
我要创建一个分叉吗? If so, how do I pull changes from upstream but also keep my changes?
如果是这样,我如何从上游提取更改同时保留我的更改? How do I resolve the conflicts that will occur when my versions of assignments have been edited?
我如何解决在我的作业版本被编辑后会发生的冲突? Etc.
等等。
Any help is greatly appreciated because, as of now, I've just been moving all of my files and then completely re-downloading the updated repo.非常感谢任何帮助,因为到目前为止,我一直在移动我的所有文件,然后完全重新下载更新的存储库。
Also, I'm using GitHub desktop另外,我正在使用 GitHub 桌面
I'm unfamiliar with GitHub Desktop, but hopefully there are simple equivalents in the GUI for these commands.我不熟悉 GitHub Desktop,但希望 GUI 中有这些命令的简单等效项。 If not, you can try with a backup branch in Git Bash (the command line).
如果没有,您可以尝试在 Git Bash(命令行)中使用备份分支。
First, stage and commit your changes by doing git add file1 file2
etc. followed by git commit -m "change x"
首先,通过执行
git add file1 file2
等,然后执行git commit -m "change x"
来git commit -m "change x"
并提交您的更改
Then, here are a few possible options to update your current branch:然后,这里有一些可能的选项来更新您当前的分支:
git pull origin master
will first fetch the content from the remote and then merge it to your current branch. git pull origin master
将首先从远程获取内容,然后将其合并到您当前的分支。 If you end up with merge conflicts, git will tell you how to proceed.git pull --ff-only
will do the above, but it's safer in that it won't create a merge commit. git pull --ff-only
将执行上述操作,但更安全,因为它不会创建合并提交。 It only updates your local master if the history is linear and it can be fast-forwarded (hence the ff-only). When in doubt, create a backup branch of your current branch with git checkout -b my-backup
before trying anything :)如有疑问,请在尝试任何操作之前使用
git checkout -b my-backup
创建当前分支的备份分支:)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.