add 2.10 notes
This commit is contained in:
		
							
								
								
									
										49
									
								
								notes/2.10-git_clone.md
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										49
									
								
								notes/2.10-git_clone.md
									
									
									
									
									
										Normal file
									
								
							| @@ -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 <repo> <dir> | ||||
| git clone --bare <repo> <dir.git> # 不含工作区,不注册,不能用git fetch | ||||
| git clone --mirror <repo> <dir.git> # 不含工作区,注册,可以用git fetch | ||||
| ``` | ||||
|  | ||||
| ```bash | ||||
| git push [<remote-repos> [refspec>]] | ||||
| git pull [<remote-repos> [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 | ||||
| ``` | ||||
|  | ||||
		Reference in New Issue
	
	Block a user