i am working on a project and i can't push my files from local machine to remote repository
it's showing error when i try to push my repository
****! [rejected] master -> master (fetch first)
error: failed to push some refs to ' .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.****
after referring i also tried $git fetch origin and $ git merge origin YOUR_BRANCH_NAME then also it dosen't works
The solution to your problem has given in the instruction. You have to run "git pull" as the remote repository contains work that you do not have in the local repository.
Running "git fetch" won't be enough as it only fetch the changes to the local repository and doesn't merge with your codes in the staging area.
If for some reason you dont want to run "git pull", then you can try the alternative commands like following:
git fetch
git merge FETCH_HEAD
git actually runs the above two commands when you run "git pull". Here FETCH_HEAD is the the reference to the codes you just fetched in the local repository.
Let me know if you don't understand any part.
Related
I am having difficulty pushing up my code to GitHub.
I have a GitHub account and have created the repo:
cd into project folder
git init
Result:
Reinitialized existing Git repository in /Users/blakeflowers/Documents/fake-news-app/.git/
git remote add origin https://github.com/devnoob-flowers/shit-they-say.git
Result:
fatal: remote origin already exists.
git add .
Results: seems to do nothing
git commit -m "Practice Push"
Results:
On branch master
nothing to commit, working tree clean
git push -u origin master
To https://github.com/devnoob-flowers/shit-they-say.git
! [rejected] master -> master (fetch first)
error: failed to push some refs to 'https://github.com/devnoob-flowers/shit-they-say.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 clearly I have no idea what the heck is going on.
Once again im trying to push my code up to GitHub and eventually deploy the site using Github pages. just something im doing for practice.
I solved it by finding some terminal code but I don't understand it. Can anyone explain?
This solved my problem:
git fetch origin master:tmp
git rebase tmp
git push origin HEAD:master
git branch -D tmp
I am trying to push to a repository that unfortunately got severed from my client terminal in my text editor.
The error that comes up is:
! [rejected] master -> master (non-fast-forward)
error: failed to push some refs to 'https://github.com/jboyle1/milestoneproject-004.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.
So I try and:
git pull repo_name
but it says:
remote: Repository not found.
Its probably a simple fix but I'm struggling.
It should be simply git pull (or git pull origin master)
Check the output of git remote -v, and see if "origin" does reference the remote repository URL.
My repository name at my local machine is "firsthand". I have made some changes to my file (named "index.html") and have committed them to my local repository. Now I want to commit those changes to my remote repository using git push. But when i do, it is giving me following errors. (My username at www.github.com is shobhit9192#gmail.com). Plz help
C:\Users\SHOBIT\firsthand>git push
To https://github.com/shobhit9192/firsthand.git
! [rejected] gh-pages -> gh-pages (fetch first)
error: failed to push some refs to 'https://github.com/shobhit9192/firsthand.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.
This indicates someone else has pushed work you do not currently have on your local repository.
You will have to integrate the remote changes (like the hint said) before you can push local changes.
(i've only tried this on the linux command-line, since I don't use windows)
Try:
git fetch origin
git pull origin (brachname)
git push origin (brachname)
Please attempt to read the hints/error messages, they are often self-explanatory.
I can't push to github. I think I have made changes in my code through github website before and now it gives me a hint when I do git push origin master:
! [rejected] master -> master (non-fast-forward)
error: failed to push some refs to 'https://github.com/hrvoojex/telecom-toplist.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.
Do I just have to do:
git pull origin master
and after that I will be able to do:
git push origin master
I made a lot of changes in my code localy so I don't want to lose al of my work till now from the last commit.
Basically you have got two solutions:
If your local copy is the good one, you may want to overwrite the remote work. You can do that with a simple force push.
git push -f origin master
If you want both changes, you can merge remote work to local one, and then push the result. In that case, the suggested commands are the way to go.
I'm using sourceTree.
How can I push an existing local project (branch) to
a remote Gitbug repository I won?
I try and get this error:
git -c diff.mnemonicprefix=false -c core.quotepath=false push -v --tags --set-upstream memPic master:master
Pushing to https://github.com/elad2109/memPic.git
To https://github.com/elad2109/memPic.git
! [rejected] master -> master (non-fast-forward)
error: failed to push some refs to 'https://github.com/elad2109/memPic.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.
Completed with errors, see above
but anyway I'm not sure what are the required steps?
This is not a github problem but a git problem. You can't make a non-fast-forward push without merging/rebasing. Please check the corresponding parts of the documentation.
This site is a great help for understanding the problem!
So you basically either have to git pull or git pull --rebase.
This is failing because the tip of your branch is behind its remote. This might happen if there was a fetch without a rebase.
There are two ways to fix. To keep the remote changes add git rebase, before your command. To discard the other changes (not recommended) add a -f to your push command.