⑤. 移除无效的远程仓库 git remote rm
如果因为一些原因想要移除一个远程仓库 ,可以使用 git remote rm
注意:此命令只是从本地移除远程仓库的记录,并不会真正影响到远程仓库
Administrator@SD-20191128LXMQ MINGW64 /d/gitRepos/rep03/git-demo (master) $ git remote rm origin Administrator@SD-20191128LXMQ MINGW64 /d/gitRepos/rep03/git-demo (master) $ git remote -v
⑥. 从远程仓库中抓取代码 git fetch
- git fetch 是从远程仓库获取最新版本到本地仓库,不会自动merge
不会自动merge:就是你使用git fetch origin master 没有代码拉去下来
⑦. 从远程仓库拉取代码 git pull 分支别名 分支名称
- git pull 是从远程仓库获取最新版本并merge到本地仓库
Administrator@SD-20191128LXMQ MINGW64 /d/gitRepos/rep03/git-demo (master) $ git remote add git-demo https://github.com/Tz845195485/git-demo.git Administrator@SD-20191128LXMQ MINGW64 /d/gitRepos/rep03/git-demo (master) $ git remote -v git-demo https://github.com/Tz845195485/git-demo.git (fetch) git-demo https://github.com/Tz845195485/git-demo.git (push) Administrator@SD-20191128LXMQ MINGW64 /d/gitRepos/rep03/git-demo (master) $ git pull git-demo master From https://github.com/Tz845195485/git-demo * branch master -> FETCH_HEAD * [new branch] master -> git-demo/master Already up to date.
⑧. 推送到远程仓库 git push
Administrator@SD-20191128LXMQ MINGW64 /d/gitRepos/repo1 (master) $ git push git-demo master Enumerating objects: 4, done. Counting objects: 100% (4/4), done. Delta compression using up to 12 threads Compressing objects: 100% (2/2), done. Writing objects: 100% (3/3), 284 bytes | 284.00 KiB/s, done. Total 3 (delta 0), reused 0 (delta 0), pack-reused 0 To https://github.com/Tz845195485/git-demo.git 0c17f90..5ed2aaa master -> master
②. 此时发现已将我们master分支上的内容推送到GitHub创建的远程仓库
③. git push origin [local] : [remote]
$ git push origin 0-TANGZHI:O-TANGZHI Enumerating objects: 146, done. Counting objects: 100% (146/146), done. Delta compression using up to 8 threads Compressing objects: 100% (77/77), done. Writing objects: 100% (111/111), 7.80 KiB | 380.00 KiB/s, done. Total 111 (delta 28), reused 0 (delta 0), pack-reused 0 remote: Resolving deltas: 100% (28/28), completed with 1 local object. remote: Powered by GITEE.COM [GNK-6.1] remote: Create a pull request for 'O-TANGZHI' on Gitee by visiting: remote: https://gitee.com/tangzhi520/demo/pull/new/tangzhi520:O-TANGZHI...tangzhi520:master To https://gitee.com/tangzhi520/demo.git * [new branch] 0-TANGZHI -> O-TANGZHI
- ①. 当你想分享你的代码时,可以将其推送到远程仓库。 命令形式:git push [分支别名] [branch-name]