Git 命令

1、提交代码流程

git branch -va

git checkout release

git pull

git status

git add pom.xml / git add *

git commit -m “TAPD ID:278”

git push

 

git 删除远程分支

git push origin :branch-name

冒号前面的空格不能少,原理是把一个空分支push到server上,相当于删除该分支。

git push origin :upgrade_redis_util

 

git 删除本地分支

git branch -d xxxxx

 

git 删除撤销commit

git reset - -hard commit_id  代码也会回退回去

git reset - -soft commit_id  代码不会回退回去,只会退commit_id

 

git checkout . #本地所有修改的。没有的提交的,都返回到原来的状态

git stash #把所有没有提交的修改暂存到stash里面。可用git stash pop恢复。

 

git commit - -amend 修改commit 注释

 

mvn install -Dmaven.test.skip=true  maven编译时跳过对Test部分的编译。

 

git revert 撤销 某次操作,此次操作之前和之后的commit和history都会保留,并且把这次撤销作为一次最新的提交

 

git format-patch 1ebbbfaa89202b2025f4113715b345eabd988624..dab5bf0118e9d096c129cc0084e49a985f97da7a

git reset --hard 3129f73d271210aac490e5066a75932e28c5a12c

git am 0001-RM-ID-4630.patch

git push -f

 

 

git stash apply stash@{1}

 

history 查看命令历史

eg:

wenyunlideMacBook-Air:biz-oa-contract-web wenyunli$ history

   63  git add .

   64  git commit -m "RM ID:16187"

   65  git push

   66  git status

   67  git add .

   68  git commit -m "RM ID:16187"

   69  git puhs

   70  git push

   71  cd code/sql/mysql_db_scripts/

   72  git pull

   73  open .

   74  clear

 

!74 执行74那条命令 

wenyunlideMacBook-Air:biz-oa-contract-web wenyunli$ !532

pwd

/Users/wenyunli/code/biz-oa-contract-web

原文地址:https://www.cnblogs.com/-wyl/p/7640804.html