1

I have a local git project that contains some branches (master & others) i would like to push it to a new gitlab repo so: 1. I created a new gitlab repo with:

Initial commit

then i run

git commit -am "some message" git add remote gitlab <url-to-repo.git> git push gitlab master

it dosent work and shows:

! [rejected] master -> master (fetch first)

error: failed to push some refs to 'https://gitlab.com/myName/myrepo.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.

when i tried: git push gitlab master -f it dosent work also, and get:

error: failed to push some refs to 'https://gitlab.com/myName/myrepo.git

and the same result if i add: --force or -f option

1
  • 1
    See what git tries to tell you : you need to pull (to get the most recent changes on remote master) before pushing onto it. Pushing "harder" (with --force) is not a solution as git is a very stubborn animal ;-) Commented Nov 15, 2018 at 9:24

3 Answers 3

1

Just follow git advices - first, try to execute git pull -> it'll merge origin with local branches -> and then try git push.

Sign up to request clarification or add additional context in comments.

Comments

0

I found the answer: It's to create an empty gitlab repo ( ( The error was that the last time i initialized it with README)

it works fine

Comments

0

Try to execute "git fetch", and check if you are on the master branch.

Navigate to the branch and try git pull on here, and move to the origin branch and try git pull again.

The next step is try to push your local changes.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.