M
M
massef2015-02-16 11:30:36
git
massef, 2015-02-16 11:30:36

What's wrong with push in Git?

Hello! I'm learning Git, when I push to the server, I get this error, what does it mean?

! [rejected]        master -> master (fetch first)
error: failed to push some refs to 'https://github.com/...'
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.

My actions:
1. Forked the project
2. Created a folder on the computer, wrote git init
3. git clone ...
4. git status
5. git add .
6. git status
7. git commit -m "text"
8. git push -u name-repo master
Am I doing the right thing at all?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
V
Victor, 2015-02-16
@v_decadence

git initnot needed if later used git clone.
The error is due to the fact that the server has changes that you do not have in the local repository.
Must be done git pullbefore git push.

D
druid3, 2015-04-07
@druid3

...another option is to use the --force (-f) option - it ignores this error in particular...

D
dima_velikii, 2022-02-05
@dima_velikii

Need to do git pull before git push. This is a really working one!!!

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question