From 31f7a8f26d7fd96abec67becb2e10ee05feed39b Mon Sep 17 00:00:00 2001 From: Mhrooz Date: Thu, 22 Aug 2024 19:43:28 +0200 Subject: [PATCH] add 2.10 notes --- notes/2.10-git_clone.md | 49 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 notes/2.10-git_clone.md diff --git a/notes/2.10-git_clone.md b/notes/2.10-git_clone.md new file mode 100644 index 0000000..4f02484 --- /dev/null +++ b/notes/2.10-git_clone.md @@ -0,0 +1,49 @@ +## 2.10 git clone建立版本库克隆 + +### 2.10.1 + +!()[https://www.worldhello.net/gotgit/images/git-clone-pull-push.png] + +```bash +git clone +git clone --bare # 不含工作区,不注册,不能用git fetch +git clone --mirror # 不含工作区,注册,可以用git fetch +``` + +```bash +git push [ [refspec>]] +git pull [ [refspec>]] +``` + +### 2.10.2 test + +对本地的git仓库进行backup +```bash +git clone /path/to/my/workspace/demo /path/to/my/workspace/demo-backup +``` + +此时从主仓库到备用仓库中push是无法push的,因为备用仓库不是bare repo,用工作目录,直接更新会导致工作目录和最新的commit不一致,很奇怪。 + +此时应该从备用仓库中git pull。 + +git clone会自动在本地仓库中说明远程仓库是在哪 +```bash +git remote -v +``` + +### 2.10.3 推送到裸仓库中 + +```bash +git push /path/to/bare/repo.git +``` + +### 2.10.4 创建裸版本仓库 + +```bash +git init --bare demo-init.git +``` + +```bash +git push /path/to/repo.git master:master #如果碰见没有指定的推送,需要加上master:master +``` +