Git:推拒绝 [英] Git: Push rejected

查看:129
本文介绍了Git:推拒绝的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个团队,我们正在开展一个项目。我们的一个团队成员在GitHub上创建了一个存储库,并将其他人添加为合作者。我的团队成员将我们的代码提交到此存储库。我做了部分更改,当我尝试提交时,出现错误。



这就是我所做的:

  git remote add origin https://github.com/xxx/xxx.git(添加一个仓库,我是一个合作者)

`git push原产大师
到https://github.com/xxx/xxx.git
! [被拒绝] master - > master(获取第一个)
错误:未能将某些参考推送到'https://github.com/xxx/xxx.git'
提示:更新被拒绝,因为远程包含的工作是您执行
提示:不在本地。这通常是由另一个存储库推动
hint:引起的。在再次推送之前,您可能需要先集成远程更改
提示:(例如,'git pull ...')。
提示:有关详细信息,请参阅'git push --help'中的'关于快速转发的注意事项'。

git pull原点大师
警告:没有常见提交
remote:计数对象:145,完成。
remote:压缩对象:100%(60/60),完成。
remote:总计145(增量67),重用145(增量67),重复使用0
接收对象:100%(145/145),55.90 KiB | 0字节/秒,完成。
解决三角洲问题:完成100%(67/67)。
从https://github.com/xxx/xxx
*分支大师 - > FETCH_HEAD
* [新分支] master - >或/ master
fatal:拒绝合并不相关的历史记录

我只想更新我的部分并将其提交到存储库。

谢谢

解决方案

外观就像你的两个master主分支已经发生了分歧。

$ $ $ $ $ $ $ $ $ $ checkout master

#在新分支上的主人
$ git checkout -b diverged.master

#获得原产地主人
$ git checkout master
$ git fetch origin master
$ git reset --hard origin / master

#为分散功能创建一个新分支
$ git checkout -b feature.branch

#将您的分歧变更合并到新功能分支中
$ git合并diverged.master

#执行任何冲突解决方案

#合并功能分支到master
$ git checkout master
$ git merge feature.branch

#推送到远程
$ git push origin master

编辑

关于这是一个全新的回购..使这个sli ghtly更容易

 #在你的主人头上
$ git checkout master

#你的主人在一个新的分支
$ git checkout -b diverged.master

#删除主分支
#git分支-D主

#拉主从原产地
$ git pull原产地主人

#原产地主人的头部
$ git结帐原产地主人
$ git pull#好的计量

#合并您的更改
$ git merge diverged.master

#推送您的更改
$ git push origin master


I have a team and we are working on a project. One of our teammembers created a repository on GitHub and add others as collaborators. My team member committed our code to this repository. I did changes in my part and when I try to commit it, I have an error. How can I commit changes to a repository in which I'm a collaborator?

That is what I did:

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

I just want to update my part and commit it to the repository. I dont have my own repository.

Thank you

解决方案

Looks like your two master branches have diverged.

# 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

Edit

I missed the part about this being a brand new repo.. makes this slightly easier

# 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

这篇关于Git:推拒绝的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆