git-learner/notes/2.10-git_clone.md
2024-08-22 19:43:28 +02:00

1.1 KiB
Raw Blame History

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