简体   繁体   English

将远程克隆的存储库推送到我自己的github存储库,使其可更新

[英]push a remote cloned repo to my own github repo, keep it updatable

I found some similar questions but they are slightly different from what I need here. 我发现了一些类似的问题,但它们与我在这里所需要的略有不同。 I am study the mit6.828 jos course. 我正在研究mit6.828的课程。 For the lab section. 对于实验室部分。 They use their own repo to distribute and track lab code. 他们使用自己的存储库来分发和跟踪实验室代码。 They have few labs, which is build one upon another. 他们很少有实验室,它们彼此之间建立起来。 I cloned the lab repo to my local disk. 我将实验室存储库克隆到了本地磁盘。 I want to track my progress in my github repo. 我想在我的github存储库中跟踪我的进度。 I wan't able to push the untouched folder to my repo. 我无法将未修改的文件夹推送到我的仓库中。

My question is how could I use my github to track my progress to the lab1, and later update the repo to lab2, and keep working on it and so on. 我的问题是我该如何使用github跟踪我到lab1的进度,然后将存储库更新到lab2,并继续进行操作,依此类推。 I found this thread, Cloning a repo from someone else's Github and pushing it to a repo on my Github , but it seems not work as I needed. 我找到了这个线程, 从其他人的Github上克隆了一个仓库,并将其推送到我的Github上的仓库中 ,但是它似乎无法按我的需要工作。 I also find this help document from github, I think they are related solution, but I don't quite understand. 我也从github找到了这个帮助文档 ,我认为它们是相关的解决方案,但是我不太了解。 Anyone can understand it please help.Thank you. 任何人都可以理解它,请帮忙。谢谢。

You can do like this: 您可以这样:

# clone the first lab into dir "course"
# note: the repository will be named as the "origin" remote automatically
git clone http://pdos.csail.mit.edu/6.828/2012/labs/lab1/ course

# do some work
git commit -m 'I made something...'

# add a remote for your repo on github and push to it
git remote add github YOUR_GITHUB_URL
git push -u github master

# lab2 is out, let's update origin
git fetch origin

# merge lab2 in your master
git merge origin/lab2

# do some work
git commit -m 'I made something...'

# push to github
git push

When lab3 becomes available, you can just repeat the steps from git fetch origin . 当lab3可用时,您可以从git fetch origin重复这些步骤。

Let me know if any of these steps is not clear enough. 让我知道这些步骤是否还不够清楚。

Your question sounds like it should be solved by the answer you link to, but here's a simple example: 您的问题听起来似乎应该通过链接到的答案来解决,但这是一个简单的示例:

# Add your repository as a remote
git remote add myrepo https://github.com/me/myrepo

# Update from the MIT repository
git pull origin

# Push to your repository
git push myrepo

Basically you're just specifying whether you want to pull from (or push to) your repository or the MIT one. 基本上,您只是指定是要从存储库还是从MIT仓库中提取(或推入)。

Update If your new labs are added as branches to the remote repo and you want to merge your changes from lab1 into lab2 you can do this: 更新如果将新实验室作为分支添加到远程仓库中,并且您希望将对Lab1的更改合并到lab2中,则可以执行以下操作:

git branch --track lab2 origin/lab2
git merge lab1 
git push myrepo

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM