首页 > 技术文章 > 使用git

yongan140621 2019-05-22 15:39 原文

git 主要包括本地库,工作区 和 远程库

在本机中操作与工作区交互

1.首先配置git的用户名和email,并查看

  git config --global user.name "yourname"

  git config --global user.email "youremail"

  git config user.name

  git config user.email

2.查询git状态

  git status

  

 

3.新增文件或目录到工作区并提交

  git add xxx.txt

  git commit -m "commit message"

   

 

4.查看提交日志并回退版本号

  git log    (对每一次都生成一个版本号)

  

  git reset xxxxxxxxx     (输入版本号)

   

 

5.删除工作去的文件,或者从工作区检出文件

  git checkout xxx.txt     (接上面的步骤, .gitignore文件被修改了,这里checkout会发现本地文件被安照git工作区的代码覆盖)

  

  git rm xxx.txt     (git删除后本地和工作区的文件都会被删除)

   

 

6.更新本地仓库

  git pull

 

7.指定工作区某个文件回退到git提交的版本并将文件检出到本地仓库

  git checkout 

  

 

远程连接git库

https://github.com注册并新建一个自定义的仓库名,这里设置为scala,我的用户名为yongan,所以

      https://github.com/yongan/scala.git 

1.设置远程库路径(设置一个远程连接名  例如下面的scala,)

  git remote add scala https://github.com/yongan/scala.git 

2.上传工作区内容到远程库(如果无法成功提交,可能需要git pull更新)

  git push -u scala master

 

 

 

cnblogs.com/feiquan/p/11249727.html

 

推荐阅读