nerkn
nerkn

Reputation: 1980

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://[email protected]/~/erkin
 ! [rejected] master -> master (non-fast-forward)
 error: failed to push some refs to 'ssh://[email protected]/~/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.

Upvotes: 0

Views: 807

Answers (2)

Mark Longair
Mark Longair

Reputation: 467071

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.

Upvotes: 0

Adam Dymitruk
Adam Dymitruk

Reputation: 129526

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

Upvotes: 1

Related Questions