git-1

I want to upload an existing project into created repository in Gitlab which contains Readme.md file. I got some problems in terminal.

Problem 1

To https://gitlab.com/.../project.git
 ! [rejected]        master -> master (fetch first)
error: failed to push some refs to 'https://gitlab.com/.../project.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 merge the remote changes (e.g.,
hint: 'git pull') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.

Problem 2 

[rejected] master -> master (non-fast-forward)
error: failed to push some refs to 'https://gitlab.com/masyusufmufti/wisatakebumen.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.

WORKED SOLUTION

Open terminal and enter to your directory.  Below, we will create user session.

git config --global user.name "Your Name"
git config --global user.email "your_name@your_mail.com"

Following syntax, we want to start initiating git and connect to our repository.

git init

git remote add origin [//your gitlab url]

git commit -m "initial commit"
//pull those changes
git pull origin master

//now, push your work to your new repo
git push origin master

git-2

Then we check in Gitlab website, it was uploaded.

git-3

 

Source guide Gitlab Doc and Gitlab Tutorial

 

 

Advertisements