I have committed a tabs app project to a classroom repo set up by our lecturer.
I changed my mind then and want to start with a blank app.
Now I seem to have two master branches and need to delete the first.
The push triggers the following error message:
error-- ! [rejected] master -> master (non-fast-forward)
error: failed to push some refs to 'https://github.com/xxxxxxxxx/2nd-year-software-ionic-2-assignment-xxxxxxxx.git'
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Integrate the remote changes (e.g.
hint: 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
How can I get past that error message?
All you need to do is force the push:
git push --force -u origin master
That will replace the history of the remote master by the one you have locally.
Related
I can't update the source code in the repository on github.com using the following command.
$ git push -u origin master
The following error is displayed:
! \[rejected\] master -\> master (fetch first)
error: failed to push some refs to 'https://github.com/\<username\>/my-history.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.
Is there any way to do this?
I want to push the source code in the my repository.
I experienced something similar to this a few days ago.
You can do something like this:
$ git remote add origin https://github.com/username/my-repo.git
$ git push -f origin master
The error I am getting:
To https://github.com/Git-Username/Repo.git
! [rejected] master -> master (non-fast-forward)
error: failed to push some refs to 'https://github.com/user/repo.git'
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Integrate the remote changes (e.g.
hint: 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
Command I am executing:
git push origin master
I have tried nearly everything when I googled this error, I tried pulling etc.
I tried pulling etc.
pulling should have been enough to solve the issue.
But if your local history is correct (git log), and you are the only one pushig to that repository, you could also simply force push
git push --force -u origin master
That will override the history on the remote.
While i am pushing in Git I am finding the below error
! [rejected] master -> master (fetch first)
error: failed to push some refs to 'https://github.com/smitraDA/DataScienceProject2.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.
I have already Clone,Add -A, and Commit. As follows:
C:\Users\Dell-672206>git clone https://github.com/smitraDA/DataScienceProject2.git
fatal: destination path 'DataScienceProject2' already exists and is not an empty directory.
C:\Users\Dell-672206>cd DataScienceProject2
C:\Users\Dell-672206\DataScienceProject2>git add -A
C:\Users\Dell-672206\DataScienceProject2>git commit -m "version1"
I am finding the below error:
! [rejected] master -> master (fetch first)
error: failed to push some refs to 'https://github.com/smitraDA/DataScienceProject2.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.
In this situation, you have to fetch your data first from GitHub and pull all the changes from GitHub to your local repository AND then push to a remote repository. You can use the below commands:
$ git pull origin master
$ git push origin master
Trying to push a committed file to an existing remote repository on GitHub.
Below I verified and I'm trying to push to the Django. I've tried git push, and git push -u Django master. Any help would be appreciated. I have been saving all of my files locally and I am now adding all to GitHub and it's a little confusing.
Roberts-MBP:Django robertamato$ git remote -v
Django https://github.com/CodingDojo-Python-09-04/Robert_Amato.git (fetch)
Django https://github.com/CodingDojo-Python-09-04/Robert_Amato.git (push)
origin https://github.com/CodingDojo-Python-09-04/RobertAmato (fetch)
origin https://github.com/CodingDojo-Python-09-04/RobertAmato (push)
Roberts-MBP:Django robertamato$
Here is a error code it threw, I see it suggests to fetch first but I'm not to familiar with how that process works.
Roberts-MBP:Django robertamato$ git push -u Django master
To https://github.com/CodingDojo-Python-09-04/Robert_Amato.git
! [rejected] master -> master (fetch first)
error: failed to push some refs to 'https://github.com/CodingDojo-Python-09-04/Robert_Amato.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.
I messed my repository while trying to resolve conflicts. Everything was quite OK (I'm getting familiar with Git) but things got bad when I tried to reset the current branch to a previous commit (not knowing exactly what I was doing, I admit). In SourceTree, I now have 2 commits to Pull from GitHub and 10 commits to Push. When I tried to Pull, I got this:
git -c diff.mnemonicprefix=false -c core.quotepath=false fetch origin
git -c diff.mnemonicprefix=false -c core.quotepath=false pull --no-commit origin master
From https://github.com/JnLlnd/CSVBuddy
* branch master -> FETCH_HEAD
error: The following untracked working tree files would be overwritten by merge:
TEST-TheBeatles-Tab (1).txt
TEST-TheBeatles-Tab-EXPORT (1).txt
TEST-TheBeatles-Tab-EXPORT.txt
html-doc/img/review2_5_CSV Buddy_award.png
icon/csvbuddy-16x16.png
icon/csvbuddy-32x32.png
Please move or remove them before you can merge.
Aborting
I moved the 6 files and tried to Pull again. It seems to work (no error message). However, I still have the indication that there are 2 Pull to do.
If I try to Push the 10 commits, I get this error message:
git -c diff.mnemonicprefix=false -c core.quotepath=false push -v --tags origin master:master
Pushing to https://github.com/JnLlnd/CSVBuddy
To https://github.com/JnLlnd/CSVBuddy
! [rejected] master -> master (non-fast-forward)
error: failed to push some refs to 'https://github.com/JnLlnd/CSVBuddy'
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.
Hum... I think I'm not that familiar with Git ;-) What should I do?
OK. Think I got it. I still had 2 conflicts to resolve before I can Pull / Push as desired.
Thanks for reading.