1.1 KiB
1.1 KiB
2.10 git clone建立版本库克隆
2.10.1
!()[https://www.worldhello.net/gotgit/images/git-clone-pull-push.png]
git clone <repo> <dir>
git clone --bare <repo> <dir.git> # 不含工作区,不注册,不能用git fetch
git clone --mirror <repo> <dir.git> # 不含工作区,注册,可以用git fetch
git push [<remote-repos> [refspec>]]
git pull [<remote-repos> [refspec>]]
2.10.2 test
对本地的git仓库进行backup
git clone /path/to/my/workspace/demo /path/to/my/workspace/demo-backup
此时从主仓库到备用仓库中push是无法push的,因为备用仓库不是bare repo,用工作目录,直接更新会导致工作目录和最新的commit不一致,很奇怪。
此时应该从备用仓库中git pull。
git clone会自动在本地仓库中说明远程仓库是在哪
git remote -v
2.10.3 推送到裸仓库中
git push /path/to/bare/repo.git
2.10.4 创建裸版本仓库
git init --bare demo-init.git
git push /path/to/repo.git master:master #如果碰见没有指定的推送,需要加上master:master