Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

not able to clone or push existing project to gitlab

I have created one private repo, and I have the existing project on my laptop. I need to add the existing project to my repo. But when I do with terminal I am getting this below error :

remote: The project you were looking for could not be found.
fatal: repository 'https://gitlab.com/sathishchinniah/Taxi-App-User.git/' not found

Steps I followed :

**Existing folder
cd existing_folder
git init
git remote add origin https://gitlab.com/sathishchinniah/Taxi-App-User.git
git add .
git commit -m "Initial commit"
git push -u origin master**

What would be an issue for this.Please help me out.Thanks

like image 678
reddy Avatar asked May 11 '18 19:05

reddy


4 Answers

Below step solved my problem. In below command replace username with your GitLab username and project with your GitLab project name.

git remote set-url origin https://[email protected]/username/project.git

After you try to push to the master using bellow command it will popup a window to add credential to the repository.

git push -u origin master
like image 110
coder Avatar answered Nov 05 '22 04:11

coder


The problem is that you are not referencing the repository as you should for gitlab. Instead of:

https://gitlab.com/sathishchinniah/Taxi-App-User.git

You should use:

[email protected]:sathishchinniah/Taxi-App-User.git

Gitlab uses a single defined user for cloning, pushes and pulls (and every action related) and authenticates the action thru ssh keys. You should have one for the computer you are using (the one with your working copy) and register the key as a valid key for the repository on gitlab.

First, you need to have a user defined on your local git. If not, you can do as follows to configure yours:

  1. Set up your name using git config --global user.name "Your name here"
  2. Set up your email; the email must be enabled for the repository, and needs to have a private key added on the repository for permission purposes . git config --global user.email "[email protected]"

Then you should create and register you key. I can further assist you with that too if you need.

Then, depending on what you want to do or how you want to start, you have a few options:

Option 1

Clone an existing repository:

  1. Clone the repository: git clone [email protected]:namespace/project.git where “namespace” is the namespace of your group of projects, or your gitlab user (if no groups are defined) and “project” is the name of your project over gitlab
  2. Then you can simply add some files, commit them and push the commit by running: git push -u origin master

Option 2

Initialize the repository locally and then push the content to server:

  1. Initialize the repository: git init
  2. Add the remote: git remote add origin [email protected]:namespace/project.git where “namespace” is the namespace of your group of projects, or your gitlab user (if no groups are defined) and “project” is the name of your project over gitlab
  3. Then you can simply add some files, commit them and push the commit by running: git push -u origin master

Option 3

Use an existing local repository:

  1. Rename the old origin (if necessary): git remote rename origin old-origin
  2. Add the new origin: git remote add origin [email protected]:namespace/project.git where “namespace” is the namespace of your group of projects, or your gitlab user (if no groups are defined) and “project” is the name of your project over gitlab
  3. Push your branches: git push -u origin --all and git push -u origin --tags to push all tags

In your case you would like to use a new empty repository initialized locally and then push the content to repository:

git init
git remote add origin [email protected]:sathishchinniah/Taxi-App-User.git
git add .
git commit -m "Initial commit"
git push -u origin master

If it fails, please provide the errors. You should check also if you have a private key defined in your computer, and if the key is defined as a valid key for your repository at gitlab.

Hope it helps.

like image 25
muecas Avatar answered Nov 05 '22 02:11

muecas


Approach #1

While cloning the code Gitlab, add your credentials in the URL:-

git clone https://{username}:{password}@gitlab.com/.../

But this is not good from the security perspective.

Approach #2

If you are using windows, then delete the existing entries for gitlab in Windows Credential Manager. This is present under Control Panel.

enter image description here

After deleting the credential, clone the repository again, you should see a window asking for credentials.

In my case, the root cause is that I was trying to access the repository from a different account which was saved in Windows Credential Manager.

like image 2
Adarsh Singhal Avatar answered Nov 05 '22 03:11

Adarsh Singhal


Since this is a private repository, you'll need to provide credentials for this server. Try :

git remote add origin ssh://[email protected]/sathishchinniah/Taxi-App-User.git

or

git remote add origin https://[email protected]/sathishchinniah/Taxi-App-User.git

It should prompt for the password.

like image 1
J. Burke Avatar answered Nov 05 '22 04:11

J. Burke