git push rejected
I give up!
Whenever I try to push I get a stupid:
! [rejected] master -> master (non-fast forward)
error: failed to push some refs to 'git@github.com:companyX/projectX.git'
Our team has a new git setup. Instead of making private branches I now Forked our main repository (on github) to create my own copy.
At some point what I did was:
$ git fetch upstream master:upstreammaster
So here is my current setup::
$ git branch
master
* upstreammaster
$ git remote -v
origin git@github.com:userX/projectX.git
upstream git@github.com:companyX/projectX.git
where userX is my private repository.
So I go and make some changes to my upstreammaster branch, and the PULL from "upstream master".
Everything merges and stuff:
$ git pull upstream master
remote: Counting objects: 95, done.
remote: Compressing objects: 100% (60/60), done.
remote: Total 60 (delta 54), reused 0 (delta 0)
Unpacking objects: 100% (60/60), done.
From git@github.com:companyX/projectX
* branch master -> FETCH_HEAD
Merge made by recursive.
stuff | 165 ++++++++++++--------
stuff | 35 ++--
stuff | 107 ++++++++++---
stuff | 105 ++++++++++---
stuff | 24 ++--
stuff | 9 +-
stuff | 53 +++----
stuff | 44 +++---
stuff | 52 +++----
stuff | 32 +----
stuff | 4 +-
stuff | 138 ++++++++---------
stuff | 58 ++++----
stuff | 115 ++++++++------
stuff | 5 +-
stuff | 39 ++---
stuff | 28 ++--
17 files changed, 560 insertions(+), 453 deletions(-)
but then when I try to do:
$ git push upstream master
To git@github.com:companyX/projectX.git
! [rejected] master -> master (non-fast forward)
error: failed to push some refs to 'git@github.com:companyX/projectX.git'
Any help would be greately appreciated! If you need clarification please ask, I will reply!
git push
add a comment |
I give up!
Whenever I try to push I get a stupid:
! [rejected] master -> master (non-fast forward)
error: failed to push some refs to 'git@github.com:companyX/projectX.git'
Our team has a new git setup. Instead of making private branches I now Forked our main repository (on github) to create my own copy.
At some point what I did was:
$ git fetch upstream master:upstreammaster
So here is my current setup::
$ git branch
master
* upstreammaster
$ git remote -v
origin git@github.com:userX/projectX.git
upstream git@github.com:companyX/projectX.git
where userX is my private repository.
So I go and make some changes to my upstreammaster branch, and the PULL from "upstream master".
Everything merges and stuff:
$ git pull upstream master
remote: Counting objects: 95, done.
remote: Compressing objects: 100% (60/60), done.
remote: Total 60 (delta 54), reused 0 (delta 0)
Unpacking objects: 100% (60/60), done.
From git@github.com:companyX/projectX
* branch master -> FETCH_HEAD
Merge made by recursive.
stuff | 165 ++++++++++++--------
stuff | 35 ++--
stuff | 107 ++++++++++---
stuff | 105 ++++++++++---
stuff | 24 ++--
stuff | 9 +-
stuff | 53 +++----
stuff | 44 +++---
stuff | 52 +++----
stuff | 32 +----
stuff | 4 +-
stuff | 138 ++++++++---------
stuff | 58 ++++----
stuff | 115 ++++++++------
stuff | 5 +-
stuff | 39 ++---
stuff | 28 ++--
17 files changed, 560 insertions(+), 453 deletions(-)
but then when I try to do:
$ git push upstream master
To git@github.com:companyX/projectX.git
! [rejected] master -> master (non-fast forward)
error: failed to push some refs to 'git@github.com:companyX/projectX.git'
Any help would be greately appreciated! If you need clarification please ask, I will reply!
git push
@drozzy: Do you know why Git does not accept your command? Your command once worked for me. After I moved Git to another folder in my Mac, I get a similar error message.
– Léo Léopold Hertz 준영
Apr 7 '09 at 19:49
no sorry i don't know. Right now I mostly do "git push upstream master", after having merged my other branch into upstreammaster.
– drozzy
Apr 7 '09 at 21:13
See also Git push non-fast-forward updates were rejected.
– user456814
May 18 '14 at 17:06
Check your folder permissions on the git-servers repo folder for write-access (also for subdirectories!)
– xcy7e 웃
May 17 '17 at 10:26
git push can be rejected if you have two branches with similar name, in my case my second branch was named: branch1.name()+ '/specification'. Git rejected it and i solved my problem thanks to @Pat Notz
– Jannis
Oct 19 at 15:23
add a comment |
I give up!
Whenever I try to push I get a stupid:
! [rejected] master -> master (non-fast forward)
error: failed to push some refs to 'git@github.com:companyX/projectX.git'
Our team has a new git setup. Instead of making private branches I now Forked our main repository (on github) to create my own copy.
At some point what I did was:
$ git fetch upstream master:upstreammaster
So here is my current setup::
$ git branch
master
* upstreammaster
$ git remote -v
origin git@github.com:userX/projectX.git
upstream git@github.com:companyX/projectX.git
where userX is my private repository.
So I go and make some changes to my upstreammaster branch, and the PULL from "upstream master".
Everything merges and stuff:
$ git pull upstream master
remote: Counting objects: 95, done.
remote: Compressing objects: 100% (60/60), done.
remote: Total 60 (delta 54), reused 0 (delta 0)
Unpacking objects: 100% (60/60), done.
From git@github.com:companyX/projectX
* branch master -> FETCH_HEAD
Merge made by recursive.
stuff | 165 ++++++++++++--------
stuff | 35 ++--
stuff | 107 ++++++++++---
stuff | 105 ++++++++++---
stuff | 24 ++--
stuff | 9 +-
stuff | 53 +++----
stuff | 44 +++---
stuff | 52 +++----
stuff | 32 +----
stuff | 4 +-
stuff | 138 ++++++++---------
stuff | 58 ++++----
stuff | 115 ++++++++------
stuff | 5 +-
stuff | 39 ++---
stuff | 28 ++--
17 files changed, 560 insertions(+), 453 deletions(-)
but then when I try to do:
$ git push upstream master
To git@github.com:companyX/projectX.git
! [rejected] master -> master (non-fast forward)
error: failed to push some refs to 'git@github.com:companyX/projectX.git'
Any help would be greately appreciated! If you need clarification please ask, I will reply!
git push
I give up!
Whenever I try to push I get a stupid:
! [rejected] master -> master (non-fast forward)
error: failed to push some refs to 'git@github.com:companyX/projectX.git'
Our team has a new git setup. Instead of making private branches I now Forked our main repository (on github) to create my own copy.
At some point what I did was:
$ git fetch upstream master:upstreammaster
So here is my current setup::
$ git branch
master
* upstreammaster
$ git remote -v
origin git@github.com:userX/projectX.git
upstream git@github.com:companyX/projectX.git
where userX is my private repository.
So I go and make some changes to my upstreammaster branch, and the PULL from "upstream master".
Everything merges and stuff:
$ git pull upstream master
remote: Counting objects: 95, done.
remote: Compressing objects: 100% (60/60), done.
remote: Total 60 (delta 54), reused 0 (delta 0)
Unpacking objects: 100% (60/60), done.
From git@github.com:companyX/projectX
* branch master -> FETCH_HEAD
Merge made by recursive.
stuff | 165 ++++++++++++--------
stuff | 35 ++--
stuff | 107 ++++++++++---
stuff | 105 ++++++++++---
stuff | 24 ++--
stuff | 9 +-
stuff | 53 +++----
stuff | 44 +++---
stuff | 52 +++----
stuff | 32 +----
stuff | 4 +-
stuff | 138 ++++++++---------
stuff | 58 ++++----
stuff | 115 ++++++++------
stuff | 5 +-
stuff | 39 ++---
stuff | 28 ++--
17 files changed, 560 insertions(+), 453 deletions(-)
but then when I try to do:
$ git push upstream master
To git@github.com:companyX/projectX.git
! [rejected] master -> master (non-fast forward)
error: failed to push some refs to 'git@github.com:companyX/projectX.git'
Any help would be greately appreciated! If you need clarification please ask, I will reply!
git push
git push
edited Apr 7 '09 at 19:50
Léo Léopold Hertz 준영
45.9k130383598
45.9k130383598
asked Mar 6 '09 at 20:16
drozzy
21.2k38133235
21.2k38133235
@drozzy: Do you know why Git does not accept your command? Your command once worked for me. After I moved Git to another folder in my Mac, I get a similar error message.
– Léo Léopold Hertz 준영
Apr 7 '09 at 19:49
no sorry i don't know. Right now I mostly do "git push upstream master", after having merged my other branch into upstreammaster.
– drozzy
Apr 7 '09 at 21:13
See also Git push non-fast-forward updates were rejected.
– user456814
May 18 '14 at 17:06
Check your folder permissions on the git-servers repo folder for write-access (also for subdirectories!)
– xcy7e 웃
May 17 '17 at 10:26
git push can be rejected if you have two branches with similar name, in my case my second branch was named: branch1.name()+ '/specification'. Git rejected it and i solved my problem thanks to @Pat Notz
– Jannis
Oct 19 at 15:23
add a comment |
@drozzy: Do you know why Git does not accept your command? Your command once worked for me. After I moved Git to another folder in my Mac, I get a similar error message.
– Léo Léopold Hertz 준영
Apr 7 '09 at 19:49
no sorry i don't know. Right now I mostly do "git push upstream master", after having merged my other branch into upstreammaster.
– drozzy
Apr 7 '09 at 21:13
See also Git push non-fast-forward updates were rejected.
– user456814
May 18 '14 at 17:06
Check your folder permissions on the git-servers repo folder for write-access (also for subdirectories!)
– xcy7e 웃
May 17 '17 at 10:26
git push can be rejected if you have two branches with similar name, in my case my second branch was named: branch1.name()+ '/specification'. Git rejected it and i solved my problem thanks to @Pat Notz
– Jannis
Oct 19 at 15:23
@drozzy: Do you know why Git does not accept your command? Your command once worked for me. After I moved Git to another folder in my Mac, I get a similar error message.
– Léo Léopold Hertz 준영
Apr 7 '09 at 19:49
@drozzy: Do you know why Git does not accept your command? Your command once worked for me. After I moved Git to another folder in my Mac, I get a similar error message.
– Léo Léopold Hertz 준영
Apr 7 '09 at 19:49
no sorry i don't know. Right now I mostly do "git push upstream master", after having merged my other branch into upstreammaster.
– drozzy
Apr 7 '09 at 21:13
no sorry i don't know. Right now I mostly do "git push upstream master", after having merged my other branch into upstreammaster.
– drozzy
Apr 7 '09 at 21:13
See also Git push non-fast-forward updates were rejected.
– user456814
May 18 '14 at 17:06
See also Git push non-fast-forward updates were rejected.
– user456814
May 18 '14 at 17:06
Check your folder permissions on the git-servers repo folder for write-access (also for subdirectories!)
– xcy7e 웃
May 17 '17 at 10:26
Check your folder permissions on the git-servers repo folder for write-access (also for subdirectories!)
– xcy7e 웃
May 17 '17 at 10:26
git push can be rejected if you have two branches with similar name, in my case my second branch was named: branch1.name()+ '/specification'. Git rejected it and i solved my problem thanks to @Pat Notz
– Jannis
Oct 19 at 15:23
git push can be rejected if you have two branches with similar name, in my case my second branch was named: branch1.name()+ '/specification'. Git rejected it and i solved my problem thanks to @Pat Notz
– Jannis
Oct 19 at 15:23
add a comment |
6 Answers
6
active
oldest
votes
When doing a push, try specifying the refspec for the upstream master:
git push upstream upstreammaster:master
1
This works for some reason...
– drozzy
Mar 9 '09 at 12:01
3
@Jarret: It does not work for me. My code $git push git@github.com:user/repo.git git@github.com:user/repo.git:master.
– Léo Léopold Hertz 준영
Apr 7 '09 at 19:44
Masi, try without using the full URL on the second parameter: git push it@github.com:user/repo.git master
– Jarret Hardie
Apr 7 '09 at 22:55
doesn't work for me
– neoneye
Jan 27 '12 at 8:55
how to do this on zend studio?
– albanx
Aug 6 '13 at 16:02
add a comment |
Jarret Hardie is correct. Or, first merge your changes back into master and then try the push. By default, git push
pushes all branches that have names that match on the remote -- and no others. So those are your two choices -- either specify it explicitly like Jarret said or merge back to a common branch and then push.
There's been talk about this on the Git mail list and it's clear that this behavior is not about to change anytime soon -- many developers rely on this behavior in their workflows.
Edit/Clarification
Assuming your upstreammaster
branch is ready to push then you could do this:
Pull in any changes from the upstream.
$ git pull upstream master
Switch to my local master branch
$ git checkout master
Merge changes in from
upstreammaster
$ git merge upstreammaster
Push my changes up
$ git push upstream
Another thing that you may want to do before pushing is to rebase
your changes against upstream/master so that your commits are all together. You can either do that as a separate step between #1 and #2 above (git rebase upstream/master
) or you can do it as part of your pull (git pull --rebase upstream master
)
How do you mean "merge back to a common branch and then push"? Which is the common branch in this case?
– drozzy
Mar 9 '09 at 12:02
I had the same problem after checking out and working on a branch, and pushing changes that included an update to a file that had been deleted in the master branch (which I had not touched at all). Another developer tried some Git commands I didn't catch, but the problem remained:git status
showed that my branch was clean,git pull
did nothing, but the commandgit push
still outputerror: failed to push some refs...
. I finally got the problem fixed like this: 1.git checkout master
, 2.git pull
, and 3.git checkout the_branch_name
.
– Teemu Leisti
Sep 12 '12 at 8:01
er... well, and what happens when you do the first command (git pull upstream master) and you have a conflict in the pull??? You have to solve the conflict before going on??
– Raul Luna
Jun 11 '13 at 13:55
add a comment |
First, attempt to pull from the same refspec that you are trying to push to.
If this does not work, you can force a git push
by using git push -f <repo> <refspec>
, but use caution: this method can cause references to be deleted on the remote repository.
add a comment |
First use
git pull https://github.com/username/repository master
and then try
git push -u origin master
add a comment |
Is your repository at "upstream" a bare repository? I got the same error, but when I change to bare they no longer happen.
awesome, this is exactly what was causing my problem, thanks for the answer!
– adamc
Oct 10 '12 at 9:32
add a comment |
If push request is shows Rejected, then try first pull from your github account and then try push.
Ex:
In my case it was giving an error-
! [rejected] master -> master (fetch first)
error: failed to push some refs to 'https://github.com/ashif8984/git-github.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.
****So what I did was-****
$ git pull
$ git push
And the code was pushed successfully into my Github Account.
This does not provide an answer to the question. Once you have sufficient reputation you will be able to comment on any post; instead, provide answers that don't require clarification from the asker. - From Review
– Matthias
Aug 26 at 9:00
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f620253%2fgit-push-rejected%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
6 Answers
6
active
oldest
votes
6 Answers
6
active
oldest
votes
active
oldest
votes
active
oldest
votes
When doing a push, try specifying the refspec for the upstream master:
git push upstream upstreammaster:master
1
This works for some reason...
– drozzy
Mar 9 '09 at 12:01
3
@Jarret: It does not work for me. My code $git push git@github.com:user/repo.git git@github.com:user/repo.git:master.
– Léo Léopold Hertz 준영
Apr 7 '09 at 19:44
Masi, try without using the full URL on the second parameter: git push it@github.com:user/repo.git master
– Jarret Hardie
Apr 7 '09 at 22:55
doesn't work for me
– neoneye
Jan 27 '12 at 8:55
how to do this on zend studio?
– albanx
Aug 6 '13 at 16:02
add a comment |
When doing a push, try specifying the refspec for the upstream master:
git push upstream upstreammaster:master
1
This works for some reason...
– drozzy
Mar 9 '09 at 12:01
3
@Jarret: It does not work for me. My code $git push git@github.com:user/repo.git git@github.com:user/repo.git:master.
– Léo Léopold Hertz 준영
Apr 7 '09 at 19:44
Masi, try without using the full URL on the second parameter: git push it@github.com:user/repo.git master
– Jarret Hardie
Apr 7 '09 at 22:55
doesn't work for me
– neoneye
Jan 27 '12 at 8:55
how to do this on zend studio?
– albanx
Aug 6 '13 at 16:02
add a comment |
When doing a push, try specifying the refspec for the upstream master:
git push upstream upstreammaster:master
When doing a push, try specifying the refspec for the upstream master:
git push upstream upstreammaster:master
answered Mar 6 '09 at 20:31
Jarret Hardie
65.8k9111115
65.8k9111115
1
This works for some reason...
– drozzy
Mar 9 '09 at 12:01
3
@Jarret: It does not work for me. My code $git push git@github.com:user/repo.git git@github.com:user/repo.git:master.
– Léo Léopold Hertz 준영
Apr 7 '09 at 19:44
Masi, try without using the full URL on the second parameter: git push it@github.com:user/repo.git master
– Jarret Hardie
Apr 7 '09 at 22:55
doesn't work for me
– neoneye
Jan 27 '12 at 8:55
how to do this on zend studio?
– albanx
Aug 6 '13 at 16:02
add a comment |
1
This works for some reason...
– drozzy
Mar 9 '09 at 12:01
3
@Jarret: It does not work for me. My code $git push git@github.com:user/repo.git git@github.com:user/repo.git:master.
– Léo Léopold Hertz 준영
Apr 7 '09 at 19:44
Masi, try without using the full URL on the second parameter: git push it@github.com:user/repo.git master
– Jarret Hardie
Apr 7 '09 at 22:55
doesn't work for me
– neoneye
Jan 27 '12 at 8:55
how to do this on zend studio?
– albanx
Aug 6 '13 at 16:02
1
1
This works for some reason...
– drozzy
Mar 9 '09 at 12:01
This works for some reason...
– drozzy
Mar 9 '09 at 12:01
3
3
@Jarret: It does not work for me. My code $git push git@github.com:user/repo.git git@github.com:user/repo.git:master.
– Léo Léopold Hertz 준영
Apr 7 '09 at 19:44
@Jarret: It does not work for me. My code $git push git@github.com:user/repo.git git@github.com:user/repo.git:master.
– Léo Léopold Hertz 준영
Apr 7 '09 at 19:44
Masi, try without using the full URL on the second parameter: git push it@github.com:user/repo.git master
– Jarret Hardie
Apr 7 '09 at 22:55
Masi, try without using the full URL on the second parameter: git push it@github.com:user/repo.git master
– Jarret Hardie
Apr 7 '09 at 22:55
doesn't work for me
– neoneye
Jan 27 '12 at 8:55
doesn't work for me
– neoneye
Jan 27 '12 at 8:55
how to do this on zend studio?
– albanx
Aug 6 '13 at 16:02
how to do this on zend studio?
– albanx
Aug 6 '13 at 16:02
add a comment |
Jarret Hardie is correct. Or, first merge your changes back into master and then try the push. By default, git push
pushes all branches that have names that match on the remote -- and no others. So those are your two choices -- either specify it explicitly like Jarret said or merge back to a common branch and then push.
There's been talk about this on the Git mail list and it's clear that this behavior is not about to change anytime soon -- many developers rely on this behavior in their workflows.
Edit/Clarification
Assuming your upstreammaster
branch is ready to push then you could do this:
Pull in any changes from the upstream.
$ git pull upstream master
Switch to my local master branch
$ git checkout master
Merge changes in from
upstreammaster
$ git merge upstreammaster
Push my changes up
$ git push upstream
Another thing that you may want to do before pushing is to rebase
your changes against upstream/master so that your commits are all together. You can either do that as a separate step between #1 and #2 above (git rebase upstream/master
) or you can do it as part of your pull (git pull --rebase upstream master
)
How do you mean "merge back to a common branch and then push"? Which is the common branch in this case?
– drozzy
Mar 9 '09 at 12:02
I had the same problem after checking out and working on a branch, and pushing changes that included an update to a file that had been deleted in the master branch (which I had not touched at all). Another developer tried some Git commands I didn't catch, but the problem remained:git status
showed that my branch was clean,git pull
did nothing, but the commandgit push
still outputerror: failed to push some refs...
. I finally got the problem fixed like this: 1.git checkout master
, 2.git pull
, and 3.git checkout the_branch_name
.
– Teemu Leisti
Sep 12 '12 at 8:01
er... well, and what happens when you do the first command (git pull upstream master) and you have a conflict in the pull??? You have to solve the conflict before going on??
– Raul Luna
Jun 11 '13 at 13:55
add a comment |
Jarret Hardie is correct. Or, first merge your changes back into master and then try the push. By default, git push
pushes all branches that have names that match on the remote -- and no others. So those are your two choices -- either specify it explicitly like Jarret said or merge back to a common branch and then push.
There's been talk about this on the Git mail list and it's clear that this behavior is not about to change anytime soon -- many developers rely on this behavior in their workflows.
Edit/Clarification
Assuming your upstreammaster
branch is ready to push then you could do this:
Pull in any changes from the upstream.
$ git pull upstream master
Switch to my local master branch
$ git checkout master
Merge changes in from
upstreammaster
$ git merge upstreammaster
Push my changes up
$ git push upstream
Another thing that you may want to do before pushing is to rebase
your changes against upstream/master so that your commits are all together. You can either do that as a separate step between #1 and #2 above (git rebase upstream/master
) or you can do it as part of your pull (git pull --rebase upstream master
)
How do you mean "merge back to a common branch and then push"? Which is the common branch in this case?
– drozzy
Mar 9 '09 at 12:02
I had the same problem after checking out and working on a branch, and pushing changes that included an update to a file that had been deleted in the master branch (which I had not touched at all). Another developer tried some Git commands I didn't catch, but the problem remained:git status
showed that my branch was clean,git pull
did nothing, but the commandgit push
still outputerror: failed to push some refs...
. I finally got the problem fixed like this: 1.git checkout master
, 2.git pull
, and 3.git checkout the_branch_name
.
– Teemu Leisti
Sep 12 '12 at 8:01
er... well, and what happens when you do the first command (git pull upstream master) and you have a conflict in the pull??? You have to solve the conflict before going on??
– Raul Luna
Jun 11 '13 at 13:55
add a comment |
Jarret Hardie is correct. Or, first merge your changes back into master and then try the push. By default, git push
pushes all branches that have names that match on the remote -- and no others. So those are your two choices -- either specify it explicitly like Jarret said or merge back to a common branch and then push.
There's been talk about this on the Git mail list and it's clear that this behavior is not about to change anytime soon -- many developers rely on this behavior in their workflows.
Edit/Clarification
Assuming your upstreammaster
branch is ready to push then you could do this:
Pull in any changes from the upstream.
$ git pull upstream master
Switch to my local master branch
$ git checkout master
Merge changes in from
upstreammaster
$ git merge upstreammaster
Push my changes up
$ git push upstream
Another thing that you may want to do before pushing is to rebase
your changes against upstream/master so that your commits are all together. You can either do that as a separate step between #1 and #2 above (git rebase upstream/master
) or you can do it as part of your pull (git pull --rebase upstream master
)
Jarret Hardie is correct. Or, first merge your changes back into master and then try the push. By default, git push
pushes all branches that have names that match on the remote -- and no others. So those are your two choices -- either specify it explicitly like Jarret said or merge back to a common branch and then push.
There's been talk about this on the Git mail list and it's clear that this behavior is not about to change anytime soon -- many developers rely on this behavior in their workflows.
Edit/Clarification
Assuming your upstreammaster
branch is ready to push then you could do this:
Pull in any changes from the upstream.
$ git pull upstream master
Switch to my local master branch
$ git checkout master
Merge changes in from
upstreammaster
$ git merge upstreammaster
Push my changes up
$ git push upstream
Another thing that you may want to do before pushing is to rebase
your changes against upstream/master so that your commits are all together. You can either do that as a separate step between #1 and #2 above (git rebase upstream/master
) or you can do it as part of your pull (git pull --rebase upstream master
)
edited Mar 9 '09 at 13:34
answered Mar 6 '09 at 23:47
Pat Notz
129k288089
129k288089
How do you mean "merge back to a common branch and then push"? Which is the common branch in this case?
– drozzy
Mar 9 '09 at 12:02
I had the same problem after checking out and working on a branch, and pushing changes that included an update to a file that had been deleted in the master branch (which I had not touched at all). Another developer tried some Git commands I didn't catch, but the problem remained:git status
showed that my branch was clean,git pull
did nothing, but the commandgit push
still outputerror: failed to push some refs...
. I finally got the problem fixed like this: 1.git checkout master
, 2.git pull
, and 3.git checkout the_branch_name
.
– Teemu Leisti
Sep 12 '12 at 8:01
er... well, and what happens when you do the first command (git pull upstream master) and you have a conflict in the pull??? You have to solve the conflict before going on??
– Raul Luna
Jun 11 '13 at 13:55
add a comment |
How do you mean "merge back to a common branch and then push"? Which is the common branch in this case?
– drozzy
Mar 9 '09 at 12:02
I had the same problem after checking out and working on a branch, and pushing changes that included an update to a file that had been deleted in the master branch (which I had not touched at all). Another developer tried some Git commands I didn't catch, but the problem remained:git status
showed that my branch was clean,git pull
did nothing, but the commandgit push
still outputerror: failed to push some refs...
. I finally got the problem fixed like this: 1.git checkout master
, 2.git pull
, and 3.git checkout the_branch_name
.
– Teemu Leisti
Sep 12 '12 at 8:01
er... well, and what happens when you do the first command (git pull upstream master) and you have a conflict in the pull??? You have to solve the conflict before going on??
– Raul Luna
Jun 11 '13 at 13:55
How do you mean "merge back to a common branch and then push"? Which is the common branch in this case?
– drozzy
Mar 9 '09 at 12:02
How do you mean "merge back to a common branch and then push"? Which is the common branch in this case?
– drozzy
Mar 9 '09 at 12:02
I had the same problem after checking out and working on a branch, and pushing changes that included an update to a file that had been deleted in the master branch (which I had not touched at all). Another developer tried some Git commands I didn't catch, but the problem remained:
git status
showed that my branch was clean, git pull
did nothing, but the command git push
still output error: failed to push some refs...
. I finally got the problem fixed like this: 1. git checkout master
, 2. git pull
, and 3. git checkout the_branch_name
.– Teemu Leisti
Sep 12 '12 at 8:01
I had the same problem after checking out and working on a branch, and pushing changes that included an update to a file that had been deleted in the master branch (which I had not touched at all). Another developer tried some Git commands I didn't catch, but the problem remained:
git status
showed that my branch was clean, git pull
did nothing, but the command git push
still output error: failed to push some refs...
. I finally got the problem fixed like this: 1. git checkout master
, 2. git pull
, and 3. git checkout the_branch_name
.– Teemu Leisti
Sep 12 '12 at 8:01
er... well, and what happens when you do the first command (git pull upstream master) and you have a conflict in the pull??? You have to solve the conflict before going on??
– Raul Luna
Jun 11 '13 at 13:55
er... well, and what happens when you do the first command (git pull upstream master) and you have a conflict in the pull??? You have to solve the conflict before going on??
– Raul Luna
Jun 11 '13 at 13:55
add a comment |
First, attempt to pull from the same refspec that you are trying to push to.
If this does not work, you can force a git push
by using git push -f <repo> <refspec>
, but use caution: this method can cause references to be deleted on the remote repository.
add a comment |
First, attempt to pull from the same refspec that you are trying to push to.
If this does not work, you can force a git push
by using git push -f <repo> <refspec>
, but use caution: this method can cause references to be deleted on the remote repository.
add a comment |
First, attempt to pull from the same refspec that you are trying to push to.
If this does not work, you can force a git push
by using git push -f <repo> <refspec>
, but use caution: this method can cause references to be deleted on the remote repository.
First, attempt to pull from the same refspec that you are trying to push to.
If this does not work, you can force a git push
by using git push -f <repo> <refspec>
, but use caution: this method can cause references to be deleted on the remote repository.
answered Mar 6 '09 at 20:37
Rob Watson
1,97862838
1,97862838
add a comment |
add a comment |
First use
git pull https://github.com/username/repository master
and then try
git push -u origin master
add a comment |
First use
git pull https://github.com/username/repository master
and then try
git push -u origin master
add a comment |
First use
git pull https://github.com/username/repository master
and then try
git push -u origin master
First use
git pull https://github.com/username/repository master
and then try
git push -u origin master
edited Nov 21 at 2:09
Pang
6,8601563101
6,8601563101
answered Feb 18 '14 at 13:03
user2368055
255410
255410
add a comment |
add a comment |
Is your repository at "upstream" a bare repository? I got the same error, but when I change to bare they no longer happen.
awesome, this is exactly what was causing my problem, thanks for the answer!
– adamc
Oct 10 '12 at 9:32
add a comment |
Is your repository at "upstream" a bare repository? I got the same error, but when I change to bare they no longer happen.
awesome, this is exactly what was causing my problem, thanks for the answer!
– adamc
Oct 10 '12 at 9:32
add a comment |
Is your repository at "upstream" a bare repository? I got the same error, but when I change to bare they no longer happen.
Is your repository at "upstream" a bare repository? I got the same error, but when I change to bare they no longer happen.
answered Jun 22 '11 at 9:52
alekwisnia
1,44911633
1,44911633
awesome, this is exactly what was causing my problem, thanks for the answer!
– adamc
Oct 10 '12 at 9:32
add a comment |
awesome, this is exactly what was causing my problem, thanks for the answer!
– adamc
Oct 10 '12 at 9:32
awesome, this is exactly what was causing my problem, thanks for the answer!
– adamc
Oct 10 '12 at 9:32
awesome, this is exactly what was causing my problem, thanks for the answer!
– adamc
Oct 10 '12 at 9:32
add a comment |
If push request is shows Rejected, then try first pull from your github account and then try push.
Ex:
In my case it was giving an error-
! [rejected] master -> master (fetch first)
error: failed to push some refs to 'https://github.com/ashif8984/git-github.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.
****So what I did was-****
$ git pull
$ git push
And the code was pushed successfully into my Github Account.
This does not provide an answer to the question. Once you have sufficient reputation you will be able to comment on any post; instead, provide answers that don't require clarification from the asker. - From Review
– Matthias
Aug 26 at 9:00
add a comment |
If push request is shows Rejected, then try first pull from your github account and then try push.
Ex:
In my case it was giving an error-
! [rejected] master -> master (fetch first)
error: failed to push some refs to 'https://github.com/ashif8984/git-github.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.
****So what I did was-****
$ git pull
$ git push
And the code was pushed successfully into my Github Account.
This does not provide an answer to the question. Once you have sufficient reputation you will be able to comment on any post; instead, provide answers that don't require clarification from the asker. - From Review
– Matthias
Aug 26 at 9:00
add a comment |
If push request is shows Rejected, then try first pull from your github account and then try push.
Ex:
In my case it was giving an error-
! [rejected] master -> master (fetch first)
error: failed to push some refs to 'https://github.com/ashif8984/git-github.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.
****So what I did was-****
$ git pull
$ git push
And the code was pushed successfully into my Github Account.
If push request is shows Rejected, then try first pull from your github account and then try push.
Ex:
In my case it was giving an error-
! [rejected] master -> master (fetch first)
error: failed to push some refs to 'https://github.com/ashif8984/git-github.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.
****So what I did was-****
$ git pull
$ git push
And the code was pushed successfully into my Github Account.
edited Aug 26 at 10:02
knittl
150k39227279
150k39227279
answered Aug 26 at 7:23
Ashif
11
11
This does not provide an answer to the question. Once you have sufficient reputation you will be able to comment on any post; instead, provide answers that don't require clarification from the asker. - From Review
– Matthias
Aug 26 at 9:00
add a comment |
This does not provide an answer to the question. Once you have sufficient reputation you will be able to comment on any post; instead, provide answers that don't require clarification from the asker. - From Review
– Matthias
Aug 26 at 9:00
This does not provide an answer to the question. Once you have sufficient reputation you will be able to comment on any post; instead, provide answers that don't require clarification from the asker. - From Review
– Matthias
Aug 26 at 9:00
This does not provide an answer to the question. Once you have sufficient reputation you will be able to comment on any post; instead, provide answers that don't require clarification from the asker. - From Review
– Matthias
Aug 26 at 9:00
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f620253%2fgit-push-rejected%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
@drozzy: Do you know why Git does not accept your command? Your command once worked for me. After I moved Git to another folder in my Mac, I get a similar error message.
– Léo Léopold Hertz 준영
Apr 7 '09 at 19:49
no sorry i don't know. Right now I mostly do "git push upstream master", after having merged my other branch into upstreammaster.
– drozzy
Apr 7 '09 at 21:13
See also Git push non-fast-forward updates were rejected.
– user456814
May 18 '14 at 17:06
Check your folder permissions on the git-servers repo folder for write-access (also for subdirectories!)
– xcy7e 웃
May 17 '17 at 10:26
git push can be rejected if you have two branches with similar name, in my case my second branch was named: branch1.name()+ '/specification'. Git rejected it and i solved my problem thanks to @Pat Notz
– Jannis
Oct 19 at 15:23