git 使用场景总结

来源:互联网 发布:淘宝客服售前售后要点 编辑:程序博客网 时间:2024/06/06 19:26

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

4、查看远程分支

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

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

5、查看 本地分支 与 远程分支 追踪关系

git branch -vv
6、设置本地分支 与 远程分支 追踪关系
<span style="font-size:14px;"> git branch [--set-upstream | --track | --no-track] [-l] [-f] <branchname> [<start-point>] git branch (--set-upstream-to=<upstream> | -u <upstream>) [<branchname>] git branch --unset-upstream [<branchname>]</span>

7、删除远程分支和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
 将其他分支上的某一次提交 应用到 当前分支上

qiaozhiguang@NewMedicalRecords[dev*]$git cherry-pick -helpusage: git cherry-pick [<options>] <commit-ish>...   or: git cherry-pick <subcommand>    --quit                end revert or cherry-pick sequence    --continue            resume revert or cherry-pick sequence    --abort               cancel revert or cherry-pick sequence    -n, --no-commit       don't automatically commit    -e, --edit            edit the commit message    -s, --signoff         add Signed-off-by:    -m, --mainline <n>    parent number    --rerere-autoupdate   update the index with reused conflict resolution if possible    --strategy <strategy>                          merge strategy    -X, --strategy-option <option>                          option for merge strategy    -S, --gpg-sign[=<key-id>]                          GPG sign commit    -x                    append commit name    --ff                  allow fast-forward    --allow-empty         preserve initially empty commits    --allow-empty-message                          allow commits with empty messages    --keep-redundant-commits                          keep redundant, empty commits


9、git revert 

将某一次提交的 内容 撤销  

10、git reset




0 0
原创粉丝点击