# git使用
## 千万不能提交不是自己的文件
- 使用提交时, 在提交对话框时, 发现存在不是自己编辑的问题就, 一定不能提交
- 发生这种情况反映到上级
## revert文件时一定选中好文件revert, 确保你revert的是具体的文件
## 处理突然宕机破坏索引文件
rm -fr .git
git init
git remote add origin http://gitlab.baidu.com/be-fe/befe-procurement.git
git fetch
git reset --mixed origin/master
git branch --set-upstream-to=origin/master master
## 与远程仓库连接的方法
[1.初始化] git init;
[2.挂接] git remote add origin http://gitlab.baidu.com/be-fe/befe-procurement.git
[3.拉入] git pull origin master
[4.同步] git checkout origin master
## 远程文件与本地文件的一致性
如果希望保留生产服务器上所做的改动,仅仅并入新配置项, 处理方法如下:
git stash
git pull
git stash pop
然后可以使用Git diff -w +文件名 来确认代码自动合并的情况.
反过来,如果希望用代码库中的文件完全覆盖本地工作版本. 方法如下:
git reset --hard
git pull
其中git reset是针对版本,如果想针对文件回退本地修改,使用
git checkout HEAD file/to/restore
## 创建分支
$ git checkout -b iss53
Switched to a new branch "iss53"
它是下面两条命令的简写:
$ git branch iss53
$ git checkout iss53
## 合并分支的方式
//将mastr内容提交合并打到featture
git checkout feature
git merge master
## 删除分支
$ git branch -d hotfix
## ignore files syn
# 忽略*.o和*.a文件
*.[oa]
# 忽略*.b和*.B文件,my.b除外
*.[bB]
!my.b
# 忽略dbg文件和dbg目录
dbg
# 只忽略dbg目录,不忽略dbg文件
dbg/
# 只忽略dbg文件,不忽略dbg目录
dbg
!dbg/
# 只忽略当前目录下的dbg文件和目录,子目录的dbg不在忽略范围内
/dbg