1.打开仓库地址,点击Settings
2.更改仓库名称
3.回到本地,通过以下命令查看之前的仓库名
$ git remote -v
查看结果:
origin git://github.com/Chloeqq/learngit.git (fetch)
origin git://github.com/Chloeqq/learngit.git (push)
4.通过以下命令进行修改
git remote set-url origin [email protected]:Chloeqq/Pytest_Auto_APi_Master.git
查看结果:
git remote -v
origin [email protected]:Chloeqq/Pytest_Auto_APi_Master.git (fetch)
origin [email protected]:Chloeqq/Pytest_Auto_APi_Master.git (push)
- 通过以下命令,推送仓库
git push -u origin master
发现报错
To github.com:Chloeqq/Pytest_Auto_APi_Master.git
! [rejected] master -> master (fetch first)
error: failed to push some refs to 'github.com:Chloeqq/Pytest_Auto_APi_Master.git'
hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first integrate the remote changes
hint: (e.g., 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
6.上传项目
git pull --rebase origin master
发现报错
error: cannot pull with rebase: You have unstaged changes.
error: additionally, your index contains uncommitted changes.
error: please commit or stash them.
报错原因是:有未提交的更改,不能执行git pull
- 解决方案,执行以下命令
git stash
查看结果:
Saved working directory and index state WIP on master: da4758c add JK_AutoTest_Demo JK_Mall
重新拉取项目:
git pull --rebase origin master
查看结果:
remote: Enumerating objects: 157, done.
remote: Counting objects: 100% (157/157), done.
remote: Compressing objects: 100% (138/138), done.
remote: Total 157 (delta 10), reused 157 (delta 10), pack-reused 0
Receiving objects: 100% (157/157), 4.03 MiB | 861.00 KiB/s, done.
Resolving deltas: 100% (10/10), done.
From github.com:Chloeqq/Pytest_Auto_APi_Master
* branch master -> FETCH_HEAD
* [new branch] master -> origin/master
Successfully rebased and updated refs/heads/master.
重新推送项目:
git push -u origin master
查看结果:
Enumerating objects: 674, done.
Counting objects: 100% (674/674), done.
Delta compression using up to 10 threads
Compressing objects: 100% (649/649), done.
Writing objects: 100% (673/673), 1.52 MiB | 1.04 MiB/s, done.
Total 673 (delta 265), reused 1 (delta 0), pack-reused 0
remote: Resolving deltas: 100% (265/265), completed with 1 local object.
To github.com:Chloeqq/Pytest_Auto_APi_Master.git
ecf58db..a607db9 master -> master
Branch 'master' set up to track remote branch 'master' from 'origin'.