Git常用操作记录

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/lsziri/article/details/86624009

Git

Git的一些基本使用

Git alias

  1. 设置别名 git config --global xxx
    git config --global  alias.st=status
    git config --global  alias.di=diff
    git config --global  alias.ci=commit
    git config --global  alias.co=checkout
    git config --global  alias.br=branch
    
  2. 配置日志格式并设置别名:git ll
    Git Log 格式参考:https://www.cnblogs.com/bellkosmos/p/5923439.html
    git config --global  alias.ll=log --graph --pretty=format:'%C(yellow)%h%Creset -%C(cyan)%d%Creset %s %Cgreen(%an, %cr)' --abbrev-commit
    
    
    
  3. 查询配置 git config --list

Git stash 实践

git stash save 222
 -- - -- do work someing

git stash list       		 #暂存的档案
git stash pop        		 #弹出最后一次stash
git stash apply stash@{0} 	 #应用具体的某个stash

git stash list [<options>]
git stash show [<stash>]
git stash drop [-q|--quiet] [<stash>]
git stash ( pop | apply ) [--index] [-q|--quiet] [<stash>]
git stash branch <branchname> [<stash>]
git stash [save [-p|--patch] [-k|--[no-]keep-index] [-q|--quiet]
	     [-u|--include-untracked] [-a|--all] [<message>]]
git stash clear
git stash create [<message>]
git stash store [-m|--message <message>] [-q|--quiet] <commit>


日志格式解读

*号代表在对应的分支提交了代码
每列上第一个包含 分支信息的列,那么该列的提交情况就是该分支的提交情况
eg. 9ad18320 和 4c570623 是master分支
eg. a6f3784d 和 5407fc3a 是origin/branch111分支

*   9ad18320 - (HEAD -> master, origin/master) Merge pull request #129 in 仓库000 from branch-eeeee to master (user1, 18 hours ago)
|\  
| * a6f3784d - (origin/branch111) 减少条件 (user2, 18 hours ago)
| * d3782e2d - 修改master分支测试类的编译报错 (user2, 18 hours ago)
| *   c221b08d - Merge remote-tracking branch 'origin/master' into branch222 (user2, 18 hours ago)
| |\  
| |/  
|/|   
* |   a7781ec1 - Merge pull request #128 in 仓库000 from feature/xzy to master (user9, 21 hours ago)
|\ \  
| * | beb4ad2c - (origin/feature/xyzz) 商户来源 (user3, 22 hours ago)
* | |   bf0f5a8a - Merge pull request #127 in 仓库000 from feature/xzy to master (user9, 23 hours ago)
|\ \ \  
| |/ /  
| * | 5407fc3a - 默认来源 (user3, 23 hours ago)
* | |   4c570623 - Merge pull request #126 in 仓库000 from feature/xzy to master (user9, 2 days ago)
|\ \ \  
| |/ /  
| * | 67e0f470 - 恢复数据 (user3, 2 days ago)
| * | 4a458757 - page (user3, 2 days ago)

版本回退

git  reset --hard HEAD^
git  reset --hard ${commitID}

Git的操作记录

git reflog

猜你喜欢

转载自blog.csdn.net/lsziri/article/details/86624009