转自:https://i.cnblogs.com/EditPosts.aspx?opt=1

1.设置名字与邮箱

Git config –global user.name “YourName”

$ git config –global user.email your_email@whatever.com

2.设置换行符

git config --global core.autocrlf input

git config --global core.safecrlf true

3.初始化一个工程

$ mkdir hello

$ cd hello

$ git init

4.在工程目录中加入文件

$ git add hello.rb

$ git commit -m "First Commit"

5.查看当前状态

$ git status

6.查看日志文件

$ git log

7.每个记录的日志在一行内显示

git log --pretty=oneline

8.设置别名

HOME目录下的.gitconfig

[alias]

co= checkout

ci= commit

st= status

br= branch

hist = log --pretty=format:\"%h %ad | %s%d [%an]\" --graph--date=short

type = cat-file -t

dump = cat-file –p

9.将checkout point指向最新的分支

git checkout master(最近的分支)

10.为当前状态设置标签

git tag v1

11.checkout point指向v1的上一个版本

git checkout v1^(表示v1的上一个版本)

12. 查看当前的所有tag

git tag

13.设置一种输出格式

Hist log --pretty=format:\"%h %ad |%s%d [%an]\" --graph --date=short

Head表示当前的check out commit

14.当对一个文件做了改变,但是还没有staging,可以使用git checkout file来忽略对文件的改变:

git checkout hello.rb

git status

cat hello.rb

15.当对一个文件做了改变,已经staging,但是没有committing,想恢复时,首先reset到staging前的状态,再使用checkout到原始状态:

git reset HEAD hello.rb

git checkout hello.rb

16.当对一个文件做了改变,已经committing,想恢复时,首先revert,然后reset到staging前的状态,再使用checkout到原始状态:

git revert HEAD

git reset --hard v1(hard指定最近的那个分支)

git tag -d oops

17. 修正刚才的commit

git commit --amend -m "Add anauthor/email comment"

18.移动文件夹,将文件夹移动到另外一个目录时:

A.

mkdir lib

git mv hello.rb lib

git status

git commit -m "Moved hello.rb tolib"

B.

mkdir lib

mv hello.rb lib

git add lib/hello.rb

git rm hello.rb

git commit -m "Moved hello.rb tolib"

19.新增文件到repository

git add Rakefile

git commit -m "Added a Rakefile."

最新文章

  1. NOIP模板整理计划
  2. Java中图片压缩处理
  3. Maximo7自定义实现WebService
  4. 对病毒Virus.Win32.Ramnit.B的研究
  5. MYSQL基础语句
  6. phpcms不显示验证码
  7. C# 常用日期函数
  8. linux 静态库、共享库
  9. 自己制作 SPx N合1 自动安装盘(x86)
  10. MVC 使用 FluentScheduler 定时器计划任务
  11. java 数据库连接池 Oracle版
  12. C#递归搜索指定目录下的文件或目录
  13. hadoop启动守护进程报JAVA_HOME is not set and could not be found
  14. oracle 插入含&字符串
  15. WPF中StringFormat 格式化 的用法
  16. 解决java.lang.IllegalArgumentException: No converter found for return value of type
  17. ZooKeeper和Curator相关经验总结
  18. 【转载】 996是没前途的!996.ICU来了,回忆我对996的态度是如何从支持变成了怀疑!
  19. rear
  20. 解决linux下不生成core dump文件

热门文章

  1. Return Largest Numbers in Arrays-freecodecamp算法题目
  2. Hibernate知识梳理
  3. manjaro kde netease-cloud-music 网易云音乐
  4. Developing for nRF52810(转载)
  5. PTA 7-2 符号配对
  6. SDUST第十一次oj作业液晶显示问题
  7. EXCEL常用命令
  8. 小白用shiro(1)
  9. GloVe词分布式表示
  10. EM算法简易推导