Git系列之一 git usuage

1. remove remote branch:  
git push origin :VUP-17-ImplementJavascriptMaximumPopups
2. remove local branch:
git branch -d branch-name


3. give up local modify
git reset --hard


4. git ui tools
gitk


5. first time need register it to .git/config 
git submodule init 


6. get submodule code 
 git submodule update
 
7. check the commit id and see the log
git log -number


8. procuce the git diff file 
git diff --full-index oldcommitid...newcommitid > CAT-73.diffgit diff --full-index oldcommitid...newcommitid > CAT-73.diff, commitid from git log.


9. after conflict with server, and modify it, then need to execute follow command.
git am --resolved


10. git commit usual steps
a>  git pull
b>  git commit
c>  git pull
d>  git push


11. git pull --rebase do follow things:
a> template save the changes after last pull of local repo.
b> back to last pull point.
c> use remote repo change.
d> use the changes from a step.


12. when you want use others change. you need to rebase your current branch to your required branch
git rebase <new base-commit> (git rebase master)


13. merge your branch to others branch, do follow command in your others branch.
git merge yourbranch (git merge list)


14. rebase your branch to others branch specific commit
git rebase --onto <new base-commit> <current base-commit> (git rebase --onto 64a00b7e dc39a81e)


15. rebase conflict resolove.
a> manual merge conflict code.
b> git add <file (include your file relative path)>
c> git rebase --continue


16. modify commit content use the Interactive Mode of rebase.
git rebase -i yourRequiredCommit(git rebase -i 0580eab8)
pick = keep this commit, and do nothing else
reword = keep this commit, but want to modify the commit message
edit = keep this commit, but want to modify the commit content
squash = keep this commit, but will merge with the previous commit, and use this commit message
fixup = squash + and use previous commit 1message and discard this commit message
exec = execute an instruction


17. the different of git revert and git reset 
git revert :make your working tree to be clean (no modifications from the HEAD commit).
git revert HEAD~3:Revert the changes specified by the fourth last commit in HEAD and create a new commit with the reverted changes.


git reset --<mode> [<commit>] 
--<mode> value:
a> --soft only cacel some commit, but will leaves all your changed files "Changes to be committed"
b> --hard Any changes to tracked files in the working tree since <commit> are discarded.


18. combine several commit to one commit (Put serveral commits of another branch merge into current branch, but no commit message and no move head )
git merge --squash another
git commit -m "message here"
example:
current branch is VUP-10
git branch VUP-10S
git reset --hard HEAD commitid
git merge --squash VUP-10S
git commit -m "message here"


19. only use one of commits , -n no commit
git cherry-pick tagid -n




20. get the remote branch
git checkout --track -b <local branch> <remote>/<tracked branch>
(git checkout  --track -b bsquare remotes/origin/bsquare)
(git checkout -t origin/bsquare)


21. how to get remote branch list
git branch -a (-a shows all local and remote branches)
git branch -r (-r shows only remote branches)


22. how to apply the patch
1. git am abort //discard a patch
2. git-am pathofpatch  //apply a patch
3. git format-patch origin/master..master //crate an patch
4. git send-email --to=maintainer@project.com --from=me@here.com ... *.patch  //send patch


23 how to checkout the remote branch

git.exe checkout -f --track -b bsquare remotes/origin/bsquare


24 you want to merge some branch, but the history of remote branch does not make sense

其效果相当于将another分支上的多个commit合并成一个,放在当前分支上,原来的commit历史则没有拿过来。

git merge --squash another
git commit -m "message here"

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值