我在github上有一个项目,我之前一直在研究.但是,我擦掉了我的电脑,我想知道我应该在我的用户名下调用哪个git命令来再次检查我的项目,以便我可以将我的最新更改推送到我帐户下的github.
San*_*nti 138
Git clone是您正在寻找的命令:
git clone git@github.com:username/repo.git
Run Code Online (Sandbox Code Playgroud)
更新:这是官方指南:https: //help.github.com/articles/fork-a-repo
它有非常有用的内容
set*_*eth 34
首先,你需要告诉git你自己.从您的设置页面获取您的用户名和令牌.
然后运行:
git config --global github.user YOUR_USERNAME
git config --global github.token YOURTOKEN
Run Code Online (Sandbox Code Playgroud)
然后你应该能够运行:
git clone git@github.com:YOUR_USERNAME/YOUR_PROJECT.git
Run Code Online (Sandbox Code Playgroud)
Uda*_*iya 11
运行以下命令:
cd /pathToYourLocalProjectFolder
git pull origin master
Run Code Online (Sandbox Code Playgroud)
小智 8
由于您已经清除了计算机并想要再次签出您的项目,因此您可以从执行以下初始设置开始:
git config --global user.name "Your Name"
git config --global user.email youremail@domain.com
Run Code Online (Sandbox Code Playgroud)
登录您的 github 帐户,转到您要克隆的存储库,然后复制“Clone with HTTPS”下的 URL。
即使您上次设置了 SSH,也可以使用 HTTPS 克隆远程存储库:
git clone https://github.com/username/repo-name.git
Run Code Online (Sandbox Code Playgroud)
笔记:
如果您之前为远程存储库设置了 SSH,则必须将该密钥添加到 PC 上的已知主机 ssh 文件中;如果您不这样做并尝试这样做git clone git@github.com:username/repo-name.git,您将看到类似于以下内容的错误:
Cloning into 'repo-name'...
The authenticity of host 'github.com (192.30.255.112)' can't be established.
RSA key fingerprint is SHA256:nThbg6kXDoJWGl7E1IGOCspZomTxdCARLviMw6E5SY8.
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
Warning: Permanently added 'github.com,192.30.255.112' (RSA) to the list of known hosts.
git@github.com: Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
Run Code Online (Sandbox Code Playgroud)
在这种情况下,使用 HTTPS 比 SSH 更容易。
你可以通过两种方式做到这一点,
1. 将远程存储库克隆到本地主机
git clone https://github.com/user-name/repository.git
Run Code Online (Sandbox Code Playgroud)
2. 将远程存储库拉到本地主机
首先,您必须通过以下方式创建本地 git 存储库:
git init or git init repo-name
Run Code Online (Sandbox Code Playgroud)
然后,
git pull https://github.com/user-name/repository.git
Run Code Online (Sandbox Code Playgroud)
就这样,远程存储库中的所有提交和分支现在都可以在本地存储库中使用。
快乐编码,干杯 -:)
| 归档时间: |
|
| 查看次数: |
165433 次 |
| 最近记录: |