git20181122

git 在线编辑器 http://www.mdeditor.com/
git add commit diff log status 代码撤消
# git  https://github.com/gyz418/test.git

## 拉代码
> git clone xx.git

## 设置git用户的名称和邮箱
> git config --global user.name "Your Name" <br/>
> git config --global user.email "email@example.com"
  
## 查看当前用户
> git config --global user.name

## 查看所有配置
> git config --list 

## git 工作区、暂存区、版本库 
+ 工作区:开发区
+ 暂存区(比svn多出来一个暂存区)
+ 版本库  

## git 命令
> git status 查看当前文件状态 

+ 待提交文件:to be committed file
+ 修改的文件:modified file 属于工作区,无法直接提交到版本库,要先git add . 再 git commit 
+ 未提交缓存区文件 :untracked file  123

### git 添加 提交
> git add x.js   添加文件到缓存区

> git add .   添加所有文件到缓存区

> git commit -m "注释"  提交到版本库

> git commit -a -m "注释" 直接把修改的文件提交到工作区( -a 是 add 的简写)

### git 记录
> git log 查看提交记录(最新记录在最上面)  如果记录太多 可以按 回车键查看其他记录 退出 按 Q 

### git 文件对比
> git diff 查看工作区和暂存区的对比,用绿色显示出来(用处不大)

> git diff -cached(--stage) 暂存区和版本库的对比

> git diff master 工作区与版本库的差异 (用处不大)

### git 代码撤消
> git reset HEAD a.js  把暂存区的代码撤回工作区(在webstorm看不出任何差别)

> git checkout -- a.js 撤消工作区的代码,跟版本库代码一致(webstorm 撤消文件的修改 Verson Control-> Default a.js --- Revert)

> git commit -m "xx" --amend  撤消上一次的版本库提交,变成两个分支 要 git pull 合并远程代码到自己的版本 再 git push 推送到远程

### git 文件删除


##### git 细节
+ git 使用 vim 编辑器, git commit 会进入
 



# github
> new repository  添加一个仓库

# webstorm 
> webstorm会提示是否添加新文件到git,即Verson control中的 default 代表了git的暂存区 git add xxx,
unversioned files 即未处理。修改的文件默认属于工作区,但webstorm把它添加到了暂存区
View Code

 git 删除远程提交记录

用webstorm 远程提交记录可以重置掉 reset current branch to here   -hard

用代码 git push origin master -f 强制提交

方法二:纯代码 

git log -n 2  表示查看2条记录id,q退出

git reset 记录id  --hard   // 重置提交

git push origin master -f 强制提交 

 git remote -v   // 查当前仓库地址

posted @ 2018-11-22 17:46  gyz418  阅读(102)  评论(0编辑  收藏  举报