Git相关

119 阅读1分钟

Git相关

image.png

Git start command

clone

git clone 命令:将远程仓库的代码拷贝到本地,我们自己可以看到远程代码到本地,并且可以修改本地的代码 git clone http://***

git clone -b 指定分支(dev) http://*** 把远程指定分支的代码拉到本地仓库

init

git init 命令:在本地生成一个本地git库,我们每次的更改生成的快照都保存在这个.git文件中

mkdir projectDir; cd projectDir; git init

Git work on the current change

add

git add 命令:将一个或者多个文件添加到暂存区 git add .

mv

restore

rm

git rm命令:很多时候我们执行git add test.txt 命令时,是将test.txt文件提交到本地仓库里面,这个时候文件在我们的本地仓库了,我们接着就可以通过git commit来进行提交。但是我们如果中途想删除这个暂存区的文件,就要用到git rm test.txt了,删除了本地文件,但是本地暂存区的文件没有被删除,需要用到git rm --cached test.txt 或者git rm -f test.txt一步到位。

sparse-checkout

Git examine the history and state

diff

git diff 命令: 显示本地工作区的代码和暂存区的代码的区别

log

show

status

Git grow,mark and tweak your common history

branch

commit

merge

reset

git reset命令:当发现自己执行了一条命令把远程分支给搞乱了,可以反悔,回滚一步git reset --hard HEAD^,回退完了,工作区就回滚到上一个版本了,clean状态

switch

tag

Git collaborate

fetch

pull

push