not able to clone or push existing project to gitlab
Solution 1
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
Solution 2
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:
- Set up your name using
git config --global user.name "Your name here"
- 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:
- 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 - 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:
- Initialize the repository:
git init
- 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 - 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:
- Rename the old origin (if necessary):
git remote rename origin old-origin
- 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 - Push your branches:
git push -u origin --all
andgit 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.
Solution 3
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.
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.
Solution 4
This is happen you have more than one account configured in any code editor like android studio or vs code, so before pushing you have to use your username before your remote url like this
git remote set-url origin https://[email protected]/username/project.git
and then
git push -u origin master
otherwise no need to add username, you can do as normally you are doing to push like below
git init
git remote add origin https://@gitlab.com/username/project.git
git add .
git commit -m "Initial commit"
git push -u origin master*
Solution 5
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.
reddy
Updated on July 09, 2022Comments
-
reddy almost 2 years
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
-
muecas almost 6 yearsJust log in to gitlab, go to the repository, and follow the instructions to clone or to push/add remote.
-
-
reddy almost 6 yearsinstaed of this lne
git remote add origin https://gitlab.com/sathishchinniah/Taxi-App-User.git
i needs to use git remote add origin [email protected]/username/repo.git -
J. Burke almost 6 yearsTry the examples I added (your username not "username"). Make sure you don't have a / after .git