Git使用场景总结

来源:互联网 发布:gradle linux 安装 编辑:程序博客网 时间:2024/06/03 16:37

1、修改完工程后提交

git status

git stash

git pull -r

git stash pop 如果有冲突,去解决冲突 

git add .

git commit -m "tip message text"

git push


2、创建tag 并 推送到远程

git tag -l   查看tag列表

git tag tagName

git push --tags

3、删除tag

git tag -d tagName

5、查看远程分支

加上-a参数可以查看远程分支,远程分支会用红色表示出来(如果你开了颜色支持的话):

$ git branch -a  master  remote  tungway  v1.52* zrong  remotes/origin/master  remotes/origin/tungway  remotes/origin/v1.52  remotes/origin/zrong

5、删除远程分支和tag

在Git v1.7.0 之后,可以使用这种语法删除远程分支:

$ git push origin --delete <branchName>

删除tag这么用:

git push origin --delete tag <tagname>

否则,可以使用这种语法,推送一个空分支到远程分支,其实就相当于删除远程分支:

git push origin :<branchName>

这是删除tag的方法,推送一个空tag到远程tag:

git tag -d <tagname>git push origin :refs/tags/<tagname>

两种语法作用完全相同。

6、git log 查看提交日志

7、git diff 查看变更内容

8、git cherry-pick
 将其他分支上的某一次提交 应用到 当前分支上

[objc] view plain copy
  1. qiaozhiguang@NewMedicalRecords[dev*]$git cherry-pick -help  
  2. usage: git cherry-pick [<options>] <commit-ish>...  
  3.    or: git cherry-pick <subcommand>  
  4.   
  5.     --quit                end revert or cherry-pick sequence  
  6.     --continue            resume revert or cherry-pick sequence  
  7.     --abort               cancel revert or cherry-pick sequence  
  8.     -n, --no-commit       don't automatically commit  
  9.     -e, --edit            edit the commit message  
  10.     -s, --signoff         add Signed-off-by:  
  11.     -m, --mainline <n>    parent number  
  12.     --rerere-autoupdate   update the index with reused conflict resolution if possible  
  13.     --strategy <strategy>  
  14.                           merge strategy  
  15.     -X, --strategy-option <option>  
  16.                           option for merge strategy  
  17.     -S, --gpg-sign[=<key-id>]  
  18.                           GPG sign commit  
  19.     -x                    append commit name  
  20.     --ff                  allow fast-forward  
  21.     --allow-empty         preserve initially empty commits  
  22.     --allow-empty-message  
  23.                           allow commits with empty messages  
  24.     --keep-redundant-commits  
  25.                           keep redundant, empty commits  


9、git revert 

将某一次提交的 内容 撤销  

10、git reset


0 0
原创粉丝点击