我在https://github.com/railstutorial/sample_app_rails_4克隆了回购并对它进行了很多更改(我用它作为我自己的应用程序的起点),现在我想将更改的应用程序推送到回复我自己的github帐户.
如何更改链接到的github repo?
mga*_*aia 96
正如Deefour所说,您的情况与更改远程Git存储库的URI(URL)的情况并无太大差别.当您clone成为存储库时,它将remote以名称的形式添加为您的存储库origin.您现在需要做的是(因为您不再使用旧源)是更改origin的URL:
$ git remote set-url origin http://github.com/YOU/YOUR_REPO
Run Code Online (Sandbox Code Playgroud)
如果原始存储库经常更新并且您希望不时地获取这些更新,那么origin最好添加一个新的remote:
$ git remote add personal http://github.com/YOU/YOUR_REPO
Run Code Online (Sandbox Code Playgroud)
或者甚至可以打电话给旧的upstream:
$ git remote rename origin upstream
$ git remote add origin http://github.com/YOU/YOUR_REPO
Run Code Online (Sandbox Code Playgroud)
然后,只要您想要进行更改upstream,您就可以:
$ git fetch upstream
Run Code Online (Sandbox Code Playgroud)
因为这个源是一个示例存储库(似乎是一种开始的模板),我认为不需要保留它或根本不需要它 - 我会选择第一个替代方案.
Der*_*ike 43
GitHub:git clone别人的存储库和git push你自己的存储库
我将把别人的存储库称为另一个存储库.
在github.com上创建一个新的存储库.(这是你的存储库)
将其他存储库克隆到本地计算机.(如果你还没有这样做过)
git clone https://github.com/other-account/other-repository.git将本地存储库的当前" origin " 重命名为" upstream ".
git remote rename origin upstream给本地资源库的" 原产地 "指向你的资料库.
git remote add origin https://github.com/your-account/your-repository.git将本地存储库推送到github 上的存储库.
git push origin master现在,' origin '指向您的存储库,' upstream '指向另一个存储库.
git checkout -b my-feature-branch.git commit照常使用您的存储库.git pull upstream master拉从改变其他仓库到你的主分支.小智 9
你的目的可能是把这个回购放在你的上面并把它变成你的.
.git/并重新初始化.
rm -rf .git
git init
git add .
git commit -m "your commit message"
git remote add origin
git push origin master
小智 8
您可以通过从本地存储库创建新远程(通过命令行)来完成此操作.
git remote add <name> <url>
Run Code Online (Sandbox Code Playgroud)
然后你可以打电话:
git push <name> <repo_name>
Run Code Online (Sandbox Code Playgroud)
要替换已设置的默认"origin"远程,您可以运行以下命令:
git remote rm origin
git remote add origin <url>
Run Code Online (Sandbox Code Playgroud)
我认为这样做的"最礼貌的方式"是:
git checkout -b <your_branch_name>(如果您之前没有这样做)git remote add github <your_repository_ssh_url>git push github <your_branch_name>通过这种方式,您将拥有一个分支到原始仓库的仓库,您的更改将在一个单独的分支中提交.如果您想向原始仓库提交拉取请求,这种方式会更容易.
| 归档时间: |
|
| 查看次数: |
52535 次 |
| 最近记录: |