2016-11-19 8 views
1

私はチームを持っており、プロジェクトを進めています。チームメンバーの1人がGitHubにリポジトリを作成し、他の人を共同編集者として追加しました。私のチームメンバーは私たちのコードをこのリポジトリにコミットしました。私は私のところで変更を加えました。私がそれをコミットしようとすると、私は誤りがあります。私が共同編集者であるリポジトリに変更をコミットするにはどうすればよいですか?私が何をしたかであるGit:プッシュが拒否されました

git remote add origin https://github.com/xxx/xxx.git (added a repository where I'm a collaborator) 

`git push origin master 
To https://github.com/xxx/xxx.git 
! [rejected]  master -> master (fetch first) 
error: failed to push some refs to 'https://github.com/xxx/xxx.git' 
hint: Updates were rejected because the remote contains work that you do 
hint: not have locally. This is usually caused by another repository pushing 
hint: to the same ref. You may want to first integrate the remote changes 
hint: (e.g., 'git pull ...') before pushing again. 
hint: See the 'Note about fast-forwards' in 'git push --help' for details. 

git pull origin master 
warning: no common commits 
remote: Counting objects: 145, done. 
remote: Compressing objects: 100% (60/60), done. 
remote: Total 145 (delta 67), reused 145 (delta 67), pack-reused 0 
Receiving objects: 100% (145/145), 55.90 KiB | 0 bytes/s, done. 
Resolving deltas: 100% (67/67), done. 
From https://github.com/xxx/xxx 
* branch   master  -> FETCH_HEAD 
* [new branch]  master  -> or/master 
fatal: refusing to merge unrelated histories 

は、私はちょうど私の部分を更新し、リポジトリにコミットします。私は自分のリポジトリを持っていません。

はあなたの2本のマスター枝が分岐しているよう

+1

*「警告:いいえ、共通のコミット」を作る* - あなたは両方やりました空のレポから始める?あなたは正しいリモコンを持っているのですか? – jonrsharpe

+0

ラップトップには同じコードがあります。その後、私のtemmemberはレポを作成し、それにすべてのコードをコミットしました。私はコードの一部を少し変更しましたが、今はコミットできません( – AnaF

+0

変更を加える前にそのレポから抜きましたか?コードのプレ・レポ・バージョンから始める場合は、それをクローン化してから変更を追加してください – jonrsharpe

答えて

2

が見えるありがとうございます。

# HEAD at your master 
$ git checkout master 

# your master on a new branch 
$ git checkout -b diverged.master 

# get origin's master 
$ git checkout master 
$ git fetch origin master 
$ git reset --hard origin/master 

# Create a new branch for the diverged feature 
$ git checkout -b feature.branch 

# Merge your diverged changes into the new feature branch 
$ git merge diverged.master 

# Do any conflict resolutions 

# Merge feature branch to master 
$ git checkout master 
$ git merge feature.branch 

# Push to remote 
$ git push origin master 

編集

私は...これはブランドの新しいレポであることについて一部を逃したこの少し簡単に

# HEAD at your master 
$ git checkout master 

# your master on a new branch 
$ git checkout -b diverged.master 

# delete master branch 
# git branch -D master 

# pull master from origin 
$ git pull origin master 

# HEAD at origin's master 
$ git checkout origin master 
$ git pull # for good measure 

# merge your changes 
$ git merge diverged.master 

# push your changes 
$ git push origin master 
+0

すべてが動作します!!!!!!!!!!!!!!!!!!!!!!!!!!!!ありがとう!!!!! !私はそれを解決しようとしている3時間ぐらい – AnaF

+0

それを聞いてうれしい!gitは本当に強力なツールになることができます。それをチーム環境で行う。あなたが見ているように、あなたが何をしているのかが分からなければ、それはかなり厄介なかなり速くなるでしょう...幸せなコーディング:D –

関連する問題