git 常用命令

  一、Git(读音为/gɪt/。)是一个开源的分布式版本控制系统,可以有效、高速地处理从很小到非常大的项目版本管理。 [1]  Git 是 Linus Torvalds 为了帮助管理 Linux 内核开发而开发的一个开放源码的版本控制软件。

  二、相信使用过svn的版本控制,我觉得很大程度上都会觉得他是很强大的。git做为开源的版本管理方式,我个人还是非常喜欢的。

  三、常用命令

  1)初始化

git init

  2)添加文件 (.)为当前目录所有文件,当然可以指定目录

git add .

  3)本地提交

git commit -m "提交"

  4)设置远程地址

git remote add origin "git地址"

  5)同步本地文件到远程

git push -u origin master

  6)同步远程文件到本地

git pull --rebase origin master

  7)拉取远程代码

git clone <git_address>

  8)拉取分支代码

git clone -b <branch_name> <git_address>

  9)常见错误

error: git upload-pack: git-pack-objects died with error
fetal: git upload-pack: aborting due to possible repository corruption on the remote side.
remote: aborting due to possible repository corruption on the remote side
fetal: early EOF
fetal: index-pack failed

  解决:

git config --global pack.windowMemory "100m"
git config --global pack.SizeLimit "100m" 
git config --global pack.threads "1"
git config --global pack.window "0"

  四、上面是常用的命令,更多命令可以参考

  https://git-scm.com/book/zh/v2:官网

  http://www.runoob.com/git/git-tutorial.html:菜鸟教程

  

原文地址:https://www.cnblogs.com/ll409546297/p/10103363.html