http://www.liaoxuefeng.com/wiki/0013739516305929606dd18361248578c67b8067c8c017b000/


一、参数配置

$ git config --global user.name "FanHui"
$ git config --global user.email hui.fan@mail.ru
$ git config --global core.editor vim
$ git config --list

二、初始化仓库

$ git init .

三、提交文件

$ git add *.c
$ git add README //添加至被跟踪列表
$ git commit [-a] -m 'initial project version' //提交至本地仓库,-a 选项指曾经添加至跟踪列表中的文件,直接提交至本地仓库,无须再 add
$ git reset [--soft] HEAD filename //撒消更改, --soft 选项指撒消至待提交列表,否则直接撒消至未 add 状态

四、远程同步

$ git remote add origin git@github.com:kt10/zfk.git    //连接远程账号中的仓库,origin 是自定义的别名
$ git push -u origin master //将本地更改提交至远程,master 是分支名称
$ git pull //从远程拉取已更新的代码
$ git clone https://github.com/libgit2/libgit2 [LocalDir] 完整克隆远程代码库到本地,LocalDir 用于指定本地目录名称

五、查看状态

$ git status [-s]    //-s 选项输出精简信息
$ git log [-p -] [--stat] [--pretty=oneline] //-p -N 形式的参数显示更改内容,--stat 选项显示简要统计结果,--pretty=oneline 每个记录仅显示单行信息
$ git reflog //显示简明信息
$ git show [-p -]

六、解决冲突

//人工修正以后
$ git add xxx
$ git commit [-a] -m "Fix Conflict"
$ git push alias master 

七、删除 / 重命名文件

//删除
$ git rm [--cached] ... //会从跟踪列表中删除指定文件,默认同时本地磁盘文件,添加 --cached 选项则不删除原始文件
$ git commit //从本地仓库中清除
//重命名
$ git mv file_from file_to //跟踪列表与本地磁盘中的文件将同时被重命名,相当于如下三条命令的组合:
$ mv README.md README
$ git rm README.md
$ git add README 

八、分支操作

$ git branch xxxx    //创建分支 xxxx
$ git checkout xxxx //切换分支
$ git branch -D xxxx //删除分支
$ git merge xxxx //将 xxxx 合并到当前分支中 

九、.gitignore

#不跟踪的文件与目录列表
#规则如下:
# 所有空行或者以 # 开头的行都会被 Git 忽略
# 可以使用标准的 glob 模式匹配
# 匹配模式可以以(/)开头防止递归
# 匹配模式可以以(/)结尾指定目录
# 要忽略指定模式以外的文件或目录,可以在模式前加上惊叹号(!)取反
##################################################
obj/
bin/
*~
*.log
*.pid
##################################################
# temporary files which can be created if a process still has a handle open of a deleted file
.fuse_hidden* # KDE directory preferences
.directory # Linux trash folder which might appear on any partition or disk
.Trash-* # .nfs files are created when an open file is removed but is still being accessed
.nfs* # Prerequisites
*.d
##################################################
# Object files
*.o
*.ko
*.obj
*.elf # Linker output
*.ilk
*.map
*.exp # Precompiled Headers
*.gch
*.pch # Libraries
*.lib
*.a
*.la
*.lo # Shared objects (inc. Windows DLLs)
*.dll
*.so
*.so.*
*.dylib # Executables
*.exe
*.out
*.app
*.i*
*.x86_64
*.hex # Debug files
*.dSYM/
*.su
*.idb
*.pdb # Kernel Module Compile Results
*.mod*
*.cmd
modules.order
Module.symvers
Mkfile.old
dkms.conf 

...

最新文章

  1. 走进缓存的世界(三) - Memcache
  2. axis2+spring集成
  3. Sqoop:Could not load db driver class: com.microsoft.sqlserver.jdbc.SQLServerDriver
  4. Mysql Innodb 引擎优化-内存、日志、IO、其他相关参数
  5. C# 判断 当前设备的IP地址、默认网关、子网掩码在不在同一网段内
  6. PHP-----循环结构
  7. 读Effective Java笔记之one:static Factory methods instead of Constructors (静态工厂方与构造器)
  8. 控件风格19种,必须倒背如流——其实就是控件所拥有的能力,即有条件使用VCL框架所提供的(功能)代码
  9. vs2008编译FileZilla服务端源码
  10. Material使用02 图标MdIconModule、矢量图作为图标使用及改进
  11. Sphinx主索引和增量索引来实现索引实时更新的关键步骤
  12. 修改haproxy配置文件
  13. scrapy splash 之一二
  14. JDK8-新特性-附demo
  15. 自定义ScrollView 实现上拉下拉的回弹效果--并且子控件中有Viewpager的情况
  16. 判断是移动端还是PC端
  17. windows 执行bat脚本
  18. java 多线程(生产者消费者)
  19. 如何优化myeclipse.
  20. JavaScript数组与字符串常用方法总结

热门文章

  1. bzoj1047题解
  2. springboot之停止与启动服务的脚本
  3. BZOJ 3238: [Ahoi2013]差异((单调栈+后缀数组)/(后缀树))
  4. 一个类似indexOf()的功能的函数
  5. (转)NAT与NAT穿越学习总结--ICE过程讲的不错
  6. (16)centos7 日志文件
  7. go gin
  8. SPSS把一个数据样本随机分为两部分
  9. exe自启动的几种方式
  10. XVIII Open Cup named after E.V. Pankratiev. GP of SPb