昨天我創建了一個github倉庫,今天我發現我的顧問還創建了一個github倉庫。將我的存儲庫添加到他的存儲庫的最佳方式是什麼,而不會大量地使用它?過去我已經大量搞砸了,所以我只想確定一下。此外,我可能已經通過嘗試按照另一個StackOverflow帖子上的說明搞砸了。如何將github存儲庫的內容添加到另一個github存儲庫?
現在好像我有兩個分支,並輸入「git checkout master」給我我的文件,而輸入「git checkout tmp_branch」給我他的文件。我想將所有文件添加到他的存儲庫,並從現在開始使用該文件,並可能刪除我的存儲庫。
到目前爲止我所試圖做的是
[email protected]:~/rootdir$ git remote add origin https://github.com/him/his_repo.git
fatal: remote origin already exists.
[email protected]:~/rootdir$ git remote add his_repo https://github.com/him/his_repo.git
[email protected]:~/rootdir$ git push -u his_repo master
Username for 'https://github.com': [email protected]
Password for 'https://[email protected]@github.com':
To https://github.com/him/his_repo.git
! [rejected] master -> master (non-fast-forward)
error: failed to push some refs to 'https://github.com/him/his_repo.git'
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Merge the remote changes (e.g. 'git pull')
hint: before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
[email protected]:~/rootdir$ git pull his_repo
Username for 'https://github.com': [email protected]
Password for 'https://[email protected]@github.com':
warning: no common commits
remote: Counting objects: 13, done.
remote: Compressing objects: 100% (10/10), done.
remote: Total 13 (delta 0), reused 10 (delta 0)
Unpacking objects: 100% (13/13), done.
From https://github.com/him/his_repo
* [new branch] master -> his_repo/master
You asked to pull from the remote 'his_repo', but did not specify
a branch. Because this is not the default configured remote
for your current branch, you must specify a branch on the command line.
[email protected]:~/rootdir$ git checkout -b tmp_branch his_repo/master
warning: unable to rmdir mysubdir: Directory not empty
Branch tmp_branch set up to track remote branch master from repo.
Switched to a new branch 'tmp_branch'
[email protected]:~/rootdir$ git checkout -b origin/master
Switched to a new branch 'origin/master'
[email protected]:~/rootdir/subdir$ git checkout -b master
fatal: A branch named 'master' already exists.
[email protected]:~/rootdir/subdir$ git checkout master
Checking out files: 100% (2409/2409), done.
Switched to branch 'master'
[email protected]:~/rootdir$ git checkout tmp_branch
warning: unable to rmdir mysubdir: Directory not empty
Switched to branch 'tmp_branch'
[email protected]:~/rootdir$ git mv * tmp_branch/*
fatal: destination 'tmp_branch/*' is not a directory
[email protected]:~/rootdir$ cd ..
[email protected]:~/rootdir$ git checkout master
Checking out files: 100% (2409/2409), done.
Switched to branch 'master'
[email protected]:~/rootdir$ git push -u tmp_branch master
fatal: 'tmp_branch' does not appear to be a git repository
fatal: The remote end hung up unexpectedly
[email protected]:~/rootdir$ git push -u his_repo master
Username for 'https://github.com': [email protected]
Password for 'https://[email protected]@github.com':
To https://github.com/him/his_repo.git
! [rejected] master -> master (non-fast-forward)
error: failed to push some refs to 'https://github.com/him/his_repo.git'
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Merge the remote changes (e.g. 'git pull')
hint: before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
非常感謝:)
您的意思是「將我的存儲庫添加到他的存儲庫」是什麼意思?你在找什麼結果? – Chris 2014-10-26 20:25:01
理想情況下,會有一個存儲庫(他的),我會將所有的數據添加到它。我最終做的是將我的數據複製到一個臨時文件夾,刪除我的整個存儲庫,將他的數據放入一個新文件夾,然後將我的數據移動到新文件夾。 – Jessica 2014-10-26 21:37:49
有可能是一個更好的方法來做到這一點,但我是一個n00b。 – Jessica 2014-10-26 21:38:38