Github地址修改后,修改项目仓库地址

如果你修改了Github的用户名,那么你之前的项目的仓库地址会改变。

Github会自动帮你对原仓库的连接进行重定向,但是对于你代码编辑器里面的地址,github并不会自动帮你重定向。

官方网站给出的步骤如下

1.打开Git Bash命令行

2.将目录切换到你当前项目的目录

3.使用git remote -v 查看现在的远程仓库地址

4.使用set-url设置成新的远程仓库地址

5.查看验证是否修改成功

 

 

Switching remote URLs from SSH to HTTPS

  1. Open Git Bash.

  2. Change the current working directory to your local project.

  3. List your existing remotes in order to get the name of the remote you want to change.

    $ git remote -v
    > origin  [email protected]:USERNAME/REPOSITORY.git (fetch)
    > origin  [email protected]:USERNAME/REPOSITORY.git (push)
  4. Change your remote's URL from SSH to HTTPS with the git remote set-url command.

    $ git remote set-url origin https://github.com/USERNAME/REPOSITORY.git
  5. Verify that the remote URL has changed.

    $ git remote -v
    # Verify new remote URL
    > origin  https://github.com/USERNAME/REPOSITORY.git (fetch)
    > origin  https://github.com/USERNAME/REPOSITORY.git (push)

The next time you git fetchgit pull, or git push to the remote repository, you'll be asked for your GitHub username and password.

  • If you have two-factor authentication enabled, you must create a personal access token to use instead of your GitHub password.
  • You can use a credential helper so Git will remember your GitHub username and password every time it talks to GitHub.

 

你可能感兴趣的:(git)