git操作指南
本文最后更新于29 天前,其中的信息可能已经过时,如有错误请发送邮件到big_fw@foxmail.com

(一)基础篇
1:Git Commit

git commit
git commit

2.Git Branch

git branch bugFix
git checkout bugFix

3.Git Merge

git checkout -b bugFix

git commit

git checkout master

git commit

git merge bugFix

4.Git Rebase

git checkout -b bugFix
git commit
git checkout master
git commit
git checkout bugFix
git rebase master
(二)高级篇

1.分离HEAD

git checkout c4

2.相对引用(^)

git checkout bugFix^

git chekcout bugFix
git checkout HEAD^

3.相对引用2(~)

git branch -f master c6

git branch -f bugFix c0

git checkout c1

4.撤销变更

git reset HEAD^

git checkout pushed

git revert HEAD

(三)移动提交记录

1.Git Cherry-pick

git cherry-pick c3 c5 c7

2.交互式Rebase

git rebase -i HEAD~4
(四)杂项

1.只取一个提交记录

git rebase -i HEAD~3/

git cherry-pick bugFix

git branch -f master bugFix

2.提交的技巧 #1

git rebase -i HEAD~2 #修改C2和C3的顺序
git commit –amend
git rebase -i HEAD~2 #修改C3’和C2”顺序
git branch -f master

3.提交的技巧 #2

git checkout master

git cherry-pick newImage

git commit –amend

git cherry-pick caption

4.Git Tag

git tag v0 c1
git tag v1 c2
git checkout c2

5.Git Describe

git commit

(五)高级话题

1.多次Rebase

git rebase master bugFix

git rebase bugFix side

git rebase side another

git branch -f master another

2.两个父节点

git branch bugWork HEAD~^2~

3.纠缠不清的分支

git checkout one
git cherry-pick c4 c3 c2
git checkout two
git cherry-pick c5 c4 c3 c2
git branch -f three c2
二、远程
(一)远程仓库

1.Git Clone

git clone

2.远程分支

git commit
git checkout o/master
git commit

3.Git Fetch

git fetch

4.Git Pull

git pull

5.模拟团队合作

git clone
git fakeTeamwork 2
git commit
git pull

6.Git Push

git commit
git commit
git push

7.偏离的提交历史

git clone
git fakeTeamwork 1
git commit
git pull –rebase
git push

8.锁定的Master

git reset –hard o/master

git checkout -b feature C2

git push origin feature

(二)远程仓库高级操作

1.推送主分支

git fetch git rebase o/master side1

git rebase side1 side2

git rebase side2 side3

git rebase side3 master

git push

2.合并远程仓库

git checkout master
git pull origin master
git merge side1
git merge side2
git merge side3
git push origin master

3.远程追踪

git checkout -b side o/master /

git branch -f side master
git commit
git pull –rebase
git push

4.Git Push的参数

git push origin master
git push origin foo

5.Git Push的参数2

git push origin foo:master

git push origin master^:foo

6.Git Fetch的参数

git fetch origin master^:foo

git fetch origin foo:master

git checkout foo

git merge master

7.没有Source的Source

git pull origin :bar

git push origin :foo

8.Git Pull的参数

文末附加内容
暂无评论

发送评论 编辑评论


				
|´・ω・)ノ
ヾ(≧∇≦*)ゝ
(☆ω☆)
(╯‵□′)╯︵┴─┴
 ̄﹃ ̄
(/ω\)
∠( ᐛ 」∠)_
(๑•̀ㅁ•́ฅ)
→_→
୧(๑•̀⌄•́๑)૭
٩(ˊᗜˋ*)و
(ノ°ο°)ノ
(´இ皿இ`)
⌇●﹏●⌇
(ฅ´ω`ฅ)
(╯°A°)╯︵○○○
φ( ̄∇ ̄o)
ヾ(´・ ・`。)ノ"
( ง ᵒ̌皿ᵒ̌)ง⁼³₌₃
(ó﹏ò。)
Σ(っ °Д °;)っ
( ,,´・ω・)ノ"(´っω・`。)
╮(╯▽╰)╭
o(*////▽////*)q
>﹏<
( ๑´•ω•) "(ㆆᴗㆆ)
😂
😀
😅
😊
🙂
🙃
😌
😍
😘
😜
😝
😏
😒
🙄
😳
😡
😔
😫
😱
😭
💩
👻
🙌
🖕
👍
👫
👬
👭
🌚
🌝
🙈
💊
😶
🙏
🍦
🍉
😣
Source: github.com/k4yt3x/flowerhd
颜文字
Emoji
小恐龙
花!
上一篇
下一篇