ty9919 发表于 2018-9-18 08:10:53

你必须会的git-Apprentice

# 初始化git  
$ git config --global user.name "Your Name"
  
$ git config --global user.email "your_email@whatever.com"
  
#
  
# 设置换行(*unx 与 win32区别)
  
$ git config --global core.autocrlf input/ true (windows)
  
$ git config --global core.safecrlf true
  
#
  
# 为当前 目录 建库 Repositories
  
$ git init
  
# 将当前特定项目文件添加到 新建库
  
$ git add hello.py
  
# 将当前目录下所有文件添加到 新建库
  
$ git add .
  
# 提交更新并添加描述
  
$ git commit -m "First Commit"
  
#
  
# fork一个项目
  
$ git clone https://github.com/refinedKing/refinedking.github.io.git
  
#
  
# 查看当前 Repo 的信息
  
$ git status
  
#
  
# 查看当前 Branch 分支日志信息
  
$ git log
  
$ git log --pretty=oneline
  
#
  
$ git log --pretty=oneline --max-count=2
  
$ git log --pretty=oneline --since='5 minutes ago'
  
$ git log --pretty=oneline --until='5 minutes ago'
  
$ git log --pretty=oneline --author=
  
$ git log --pretty=oneline --all
  
#
  
# 更改当前 Branch 分支的日志记录格式
  
$ git log --pretty=format:'%h %ad | %s%d [%an]' --graph --date=short'
  
#
  
    让我们看一下细节:
  
    --pretty="..." 定义输出的格式
  
    %h 是提交 hash 的缩写
  
    %d 是提交的装饰(如分支头或标签)
  
    %ad 是创作日期
  
    %s 是注释
  
    %an 是作者姓名
  
    --graph 使用 ASCII 图形布局显示提交树
  
    --date=short 保留日期格式更好且更短
  
#
  
# 你的 $HOME 目录的 .gitconfig 文件中(命令别名)
  
vim ~/.gitconfig
  

  
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
  
#
  
# 如果你的 Shell 支持别名或简写
  
vim ~/.profile
  
alias gs='git status '
  
alias ga='git add '
  
alias gb='git branch '
  
alias gc='git commit'
  
alias gd='git diff'
  
alias go='git checkout '
  
alias gk='gitk --all&'
  
alias gx='gitx --all'
  
alias got='git '
  
alias get='git '
  
#
  
# 根据提交版本信息hash号,进行 Fork
  
$ git checkout
  
#
  
# 对当前 Fork 出的 Bransh 进行命名
  
$ git checkout -b greet
  
#
  
# 切换回主分支
  
$ git checkout master
  
#
  
# 切换回刚才的greet分支
  
$ git checkout greet
  
#
  
# 与master主线合并
  
git merge master


页: [1]
查看完整版本: 你必须会的git-Apprentice