Git常用的命令及其使用方法


* 学习资料
* 集中式与分布式
* Git 的中心服务器
* Git 工作流
* 分支实现
* 冲突
* Fast forward
* 分支管理策略
* 储藏(Stashing)
* SSH 传输设置
* .gitignore 文件
* Git 命令一览

学习资料

SSH 传输设置

Git 仓库和 Github 中心仓库之间的传输是通过 SSH 加密。

如果工作区下没有 .ssh 目录,或者该目录下没有 id_rsa 和 id_rsa.pub 这两个文件,可以通过以下命令来创建 SSH Key:

$ ssh-keygen -t rsa -C "[email protected]"

然后把公钥 id_rsa.pub 的内容复制到 Github “Account settings” 的 SSH Keys 中。

Git 命令一览

基础

创建版本库

打开文件目录后,首先通过git init命令把这个目录变成管理仓库

把文件添加版本库

  • 第一步,用git add告诉Git要添加的文件
$ git add name.txt
  • 第二步,用git commit告诉Git把文件提交给仓库
$ git commit -m "it show your speak"

Github推送

按照github绑定,绑定后提交只需要git push origin master

  • 常出现fatal: remote origin already exists.只需输入git remote rm origin

从github下载到本地,用$ git pull --rebase origin master即可

猜你喜欢

转载自blog.csdn.net/u014239185/article/details/81195360