无法将现有项目克隆或推送到gitlab

时间:2018-05-11 19:33:20

标签: git repository gitlab

我创建了一个私人仓库,我的笔记本电脑上有现有项目。我需要将现有项目添加到我的仓库中。但是当我使用终端时,我收到以下错误:

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

我遵循的步骤:

**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**

这对此有什么问题。请帮帮我。谢谢

5 个答案:

答案 0 :(得分:2)

下面的步骤解决了我的问题。在下面的命令中,将username替换为您的GitLab用户名,并将project替换为您的GitLab项目名称。

git remote set-url origin https://username@gitlab.com/username/project.git

尝试使用bellow命令推送至主服务器后,它将弹出一个窗口,以向存储库添加凭据。

git push -u origin master

答案 1 :(得分:2)

方法1

在克隆代码Gitlab时,请在URL中添加您的凭据:-

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

但是从安全角度来看,这不是很好。

方法2

如果您使用的是Windows,请在Windows凭据管理器中删除gitlab的现有条目。在控制面板下。

enter image description here

删除凭据后,再次克隆存储库,您应该会看到一个窗口,要求输入凭据。

在我的情况下,根本原因是我试图从保存在Windows凭据管理器中的另一个帐户访问存储库。

答案 2 :(得分:1)

发生这种情况的原因是,您在任何代码编辑器(例如android studio或vs代码)中都配置了多个帐户,因此在推送之前必须先使用用户名,然后再使用这样的远程网址

git remote set-url origin https://username@gitlab.com/username/project.git

然后

git push -u origin master

否则无需添加用户名,您可以像往常一样按如下操作进行推送

git init
git remote add origin https://@gitlab.com/username/project.git
git add .
git commit -m "Initial commit"
git push -u origin master*

答案 3 :(得分:0)

使用git config --global user.name“您的名字在这里”设置您的名字

设置您的电子邮件;必须为存储库启用电子邮件,并且需要使用

出于权限目的在存储库中添加了私钥。 git config --global user.email“ your@mail.com”

之前:

https://gitlab.com/ {gitlab_user} /project_repo.git

之后:

https:// {gitlab_user} @ gitlab.com / gitlab_user / project_repo.git

more details

答案 4 :(得分:0)

我通过以下方式解决了这个问题,

git remote set-url origin https://<USERNAME>:<PASSWORD>@<gitlab host>/path/to/repo.git

例如

git remote set-url origin https://Vikram:*********@gitlab.info.lab/testdemo/mydemo.git