简体   繁体   中英

how to git push at server

In server I created repository. In home computer I pulled. Now I made my changes and they are working, I need to push to server. Git refused to push. How can I update files in the server?

$ git push
To ssh://erkin@mornehir.com/~/erkin
 ! [rejected] master -> master (non-fast-forward)
 error: failed to push some refs to 'ssh://erkin@mornehir.com/~/erkin'
 To prevent you from losing history, non-fast-forward updates were rejected
 Merge the remote changes before pushing again.
 See the 'Note about fast-forwards' section of 'git push --help' for details.

make sure you have the remote set up if you cloned from the home repo. So in your home repo you would:

git remote add origin <url/file path to your other repo>

now you should be able to push with:

git push -u origin master

the -u will make sure you can push later with just

git push

If you cloned and did not make a bare repo, do it again and this time include the bare option.

git clone --bare <file path or url to your home repo>

This will ensure that you can push without warnings. A non-bare repo will have a working directory and will not like having that changed by outside forces.

hope this helps

That error essentially means that the history in your local repository doesn't contain that in the remote repository. Try:

 git pull

... and then try pushing again.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM