Skip to content

Git-Tutorials GIT基本使用教學:memo:

License

Notifications You must be signed in to change notification settings

meiyuan99/Git-Tutorials

 
 

Repository files navigation

a# Git-Tutorials ?箸雿輻?飛 📝

?撠?閬箏??镼輯?閎???�隞亙停蝪∪撖怠�?摮豢?嚗?靘輯???銝?memo:嚗??撟怠?喳飛?犖:smile:

憒??飛?炊??蝟暹迤:sweat_smile:

?箸雿輻?誘隞亙?摰??臬???撘????蔣??

敶梁??飛?憒??Y? SSH key

憒?甇仿?甇?Ⅱ銝??粹隤歹??臭誑?刻楝敺??曉 **.ssh鞈?憭?*嚗ㄐ?X? id_rsa 隞亙? id_rsa.pub ?拙�?獢?

??停??SSH Key嚗?*id_rsa?舐??? 嚗??賣援?脣?鳴? *id_rsa.pub?臬?? 嚗隞亙??曉???閮港遙雿犖??

摰?摰?Git 銋?嚗???蝚砌?隞嗡??停?臬閮剖??芸楛??摮?靽∠拳

git config --global user.name "twtrubiks"
git config --global user.email "[email protected]"

?臭誑頛詨隞乩?靘Ⅱ隤?西撓?交???

git config --global user.name
git config --global user.email

alt tag

Git 閮剖?鞈??亦?嚗?瑁?隞乩??誘 ( ???急???閰喟敦??摮?)嚗?

git config --list

git init ?誘

????git

git init

銋隞交?摰??冗

git init <directory>

git clone ?誘

銴ˊ憒?雿蔭蝬脣? ( 銝?銴ˊ???年 銴ˊ雿撌梁? ) alt tag

git clone ( 銴ˊ?雯?� ) SSH / HTTPS

( 憒?雿?雿輻 https ?撘? 隢?? Personal Access Tokens )

git clone git@github.com:twtrubiks/test.git

蝚砌?甈⊥??箇 SSH 霅血?嚗 YES ?喳??

憒? ( 銝??? )嚗雿?銝?頝臬?銝停???箔????冗

alt tag

Personal Access Tokens

敺?2021/8/13 ??, 憒?雿 https ?撘????

alt tag

remote: Support for password authentication was removed on August 13, 2021.
remote: Please see https://docs.github.com/en/get-started/getting-started-with-git/about-remote-repositories#cloning-with-https-urls for information on currently recommended modes of authentication.
fatal: Authentication failed for 'https://github.com/xxxxx.git/'

?????????喳???ssh key, 銋??喲�???勗????撘?

?臭誑???�?Personal Access Tokens (雿隞交?隞???甈?),

?雿? github 鋆∠? Settings -> Developer settings,

??Personal Access Tokens, ?Y?雿? token

alt tag

????雿隞亥撌勗?蝢拙?銋?????

銝?隞賢??舫��?token ?鈭???

alt tag

閮剖?摰?敺? 撠勗隞亥?鋆賭???token

alt tag

???餌 https clone ?撘?

??臭蝙?? 撣唾? + password (撌脩?銝雿輻鈭?,

?曉?寞?, 撣唾? + ????token 撠勗隞仿???clone 鈭?

憒??孵?(?�?憭批? repo git clone ?漲

???????�閬?clone 敺之??repo嚗銵?git clone ?賡?閬??瑞???嚗銝?瘜隞?

?�?clone ?�漲??:question:

?湔?????岫 ( 雿輻 django ?嗥?靘?)嚗?

git clone [email protected]:django/django.git

( 雿??潛 clone ?�閬?鈭???:triumph:)

alt tag

?亥??亦? log嚗git log`

alt tag

?岫?? branch git checkout stable/2.2.x

alt tag

???孵?(?�? clone ????

?臭誑?? --depth ?�??訾?摰?嚗陛?株牧??銝????踝??嗆????砍銵?clone 銋?嚗?

?亥??瑁? git log 雿??潛?之?? log嚗?耨??銝?雿?賭??�閬暻澆???log嚗?

銋停?航牧雿?賢?�閬?餈?10 蝑? history commit嚗??喃??芷?閬?1 蝑?( 銋停?舀?砌??�閬?

history commit )嚗�??停敺?蝙??--depth??

git clone [email protected]:django/django.git --depth 1

( 雿??潛?活敹怠?憭? )

alt tag

?亥??亦? log嚗git log`

( ??敹怎????臬??箸??靽??�?啁?銝�蝑?history commit 嚗?

憒?雿?閬?餈?10 蝑??寞? --depth 10 ?喳 )

alt tag

雿??銝�??憿??嗅?閰血???branch git checkout stable/2.2.x

( 雿??潛雿瘜???remote branch 😱

???臬??箔蝙??--depth ?貊?潭 --single-branch嚗?

?�隞亦?嗆??隞? branch??)

alt tag

銋停?航牧隞乩??拇??誘?嗅祕?舐蝑?

git clone git@github.com:django/django.git --depth 1
git clone git@github.com:django/django.git --depth 1 --single-branch

?箔?閫?捱?�?憿?瘥?憟賜??末?府?舫�見

git clone git@github.com:django/django.git --depth 1 --no-single-branch

( ?�? --single-branch 瘥?蝔凝銋?暺?嚗??箸???branch ???唬???history commit ?質? clone 銝? )

?見?店嚗停?臭誑靽? remote ??branch 鈭?

alt tag

???? remote ??branch嚗?git checkout stable/2.2.x??

alt tag

?�敺?敺格??

憒? clone ?�餈?甈∠? history嚗�?銋?閬隞?branch嚗蝙?典?銝?

git clone [email protected]:django/django.git --depth 1 --no-single-branch

憒?雿閬?摰??? ?? -b,

git clone [email protected]:django/django.git --depth 1 --no-single-branch -b stable/3.1.x

憒? clone ?�餈?甈∠? history嚗�?**銝?閬?*?嗡? branch嚗蝙?典?銝?

git clone [email protected]:django/django.git --depth 1 --single-branch

or

git clone [email protected]:django/django.git --depth 1

?游?閰喟敦?隤芣?隢???git clone

git status ?誘

git status

?臭誑霈?????? repository ( repo 摰孵 )??

alt tag

?�?桀?雿?撌乩??�?臭嗾瘛函???

撌乩??�?摮? ( Stage )

git add ?�?????隞嗆?唳摮? ( Stage ) 嚗?

?嗅??瑁?

git commit 撠勗隞交??怠??� ( Stage ) 鋆⊥??耨?寧??批捆??桀????臭???

銝�?阡� ( git commit ) 敺?憒?雿?瘝?撠極雿??遙雿耨?對???獐撌乩??�撠望"銋暹楊"?�?

git commit -m "xxxxx" ?誘嚗?m 敺頛詨?摰寞?祆活靽格 ( ? ) ?牧??

?⊿?頛詨銝�?澆停?臭誑??活?靽格鈭?暻潛??批捆 ( ?嫣噶隞亙??閫�?敹恍�?閫?迨甈?commit 靽格鈭?暻?)??

隞乩? demo ?箏銝�???冗?扳憓???Hello.py 瑼?

?嗅?雿輻 git status 閫�??? repository ( repo 摰孵 )嚗?????Hello.py ?芾◤餈質馱嚗?銝?

alt tag

?臭誑雿輻憒??誘

git add Hello.py

憿?鋆?嚗??a��?隞文??閎嚗之摰嗅隞亦?拍?

git add -p

?亥??蝙??

git commit -m "??"

git commit -m "add Hello.py"

?蝙??git status嚗???曉極雿?霈嗾瘛其???銝?

alt tag

鋆?嚗???撓??

git commit

alt tag

???歲?箇楊頛航?蝒?

alt tag

???臭誑??斤? *Ins?? ( ???萇銝? ?望?摮?i ) ?喳頛詨??

alt tag

頛詨摰???Esc?? 嚗?摰?摨???INSERT ??憭梧??亥??湔??:wq* 嚗???enter 撠望??脣?銝阡????

?游???臬???https://git-scm.com/docs/git-commit 隤芣???

憒?靽格?�敺?甈∠?commit???

??????commit 摰?敺???曇撌梁? commit ?批捆???鈭?

???隞乩蝙?典?銝?隞歹?隞?頝喳蝺刻摩閬?蝯虫?蝺刻摩雿?銝�甈∠? commit ?批捆??

git commit --amend

???舀???commit 摰?敺???曇撌望?鈭嗾??獢???add ?脣

???隞乩蝙?典?銝?隞?

git commit -m "init commit"
git add missing_file.py
git commit --amend

憒??�瘜?嗆? git commit -m "init commit" 銋?嚗?

??暹?瞍?鈭?missing_file.py ?�?獢?( commit ??閮?add ?脣 ) 嚗?

???停?臭誑雿輻 git commit --amend 靘耨?寞?敺?甈∠? commit ??

???????箔??嫣噶嚗?乩蝙?其??Y??誘銝�甈∪??亙?函?瑼?

git add .

雿??敺?曉撖行?鈭?獢銝?閬?add ?脣?????停?臭誑雿輻憒??誘?餃?瘨?add

git reset HEAD <file>

蝭?嚗楝敺???A.py 隞亙? B.py ???獢??嗅??蝙??git add . ?嚗? alt tag

雿??亙???曉撖?B.py ??瘝?閬?add ?脣嚗?隞交????停?臭誑雿輻 git reset HEAD B.py ?駁??�?

alt tag

git push ?誘

git push

撠?撘?push ??github ( or bitbucket 銋? )銝?, 憒???

alt tag

??批 - 甇瑕閮?

git log

??撠神q ?舫��??

alt tag

憒?閬箏??憭芷?嚗隞乩蝙?其???隞?

git log --pretty=oneline

??撠神q ?舫��??

alt tag

?血?摨?銋銝�?? log ?撘? 敺 😆嚗???GUI ??閬綽? 靘??箸?蝡?敺???? 嚗?

git log --graph --pretty=format:"%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset" --abbrev-commit --date=relative

alt tag

Git 銝哨?雿輻 HEAD 銵函內?桀????穿?

git reset --hard HEAD

alt tag

憒??曉閬??桀???�?銝????穿?撠勗隞乩蝙??git reset ?誘嚗?

銝????砍停?浹EAD~1嚗?

git reset --hard HEAD~1

alt tag

銝?銝�???砍停?浹EAD~2嚗?

憒?閬?摰??唳??摰??穿?

alt tag

git reset --hard ad41df36b7

--hard ?�??賂???蝔桅?????--mixed( default 嚗--hard --soft`嚗?

--hard ?�??貊陛?株圾?停?臬?銋???commit ?賭??? 摰 *銝??? 嚗�?

--soft ?�??貊陛?株圾?停?臬?銋???commit ?賭???雿?靽? 雿??極雿????�?

--hard ??--soft ???閬箏??冽?摮?憟質牧???遣霅啣之摰嗉撌勗隞亙???拍?嚗停?臭誑鈭圾隞�???撌桃??

--soft 敺?蝙?典撠???儔??commit ?蔥????commit??

alt tag

???( ad41df36b7 ) 瘝?閬?券撖恬?撖怠?撟曆?撠勗隞乩?嚗it ???整�?

?嗡??�??�??穿?蝒?予敺?鈭??單敺拙銋???閰脫�獐??

?曆??唳???commit id 閰脫�獐颲血?

???停?臭誑雿輻銝�??隞?

git reflog

alt tag

?亥???閬??啣???穿??蝙??git reset ?喳??

git reset --hard 642e7af

???瘨( 閬? )撌脩? push ?箏??commit嚗�????隞乩蝙??

git push --force

??渡陛?剔?撖急?

git push -f

?臭誑撘瑕 push????�??穿??嗅??撥??push??

*瘜冽?嚗憭犖撠??勗?????⊿?銝???--force ?車?寞?嚗??箸??�?摰喳?乩犖嚗遣霅啣隞乩蝙??revert ??

?銝?�????�隞亙遣霅啁?虫?蝔格?頛??函??孵?

git push --force-with-lease

?臭誑蝣箔?雿??靘蹂??鈭箇? commit?? 憒??犖瘥???commit push 銝嚗?撠望??⊥? push ??remote 嚗?

checkout

銋??�?git switch ??git restore.

git checkout -- file ?臭誑銝?撌乩??�?耨?對?

git checkout  -- hello.py

?賭誘 git checkout -- hello.py ?�停?荔???hello.py ?辣?典極雿??耨?孵?冽??( 銝? ) 嚗?

霈��?獢??唳?餈?甈?git commit ??git add ???�?�?

alt tag

?嗥銋隞亦 git reset ?誘?湔??�?commit??

git reset --hard xxxxxx
git reset --hard 201f40604ec3b6fa8

?芷

?蝔桃?瘜?銝�蝔格蝣箏?閬??摨思葉?芷閰脫?獢???停?典隞?git rm ?芣?嚗蒂銝?git commit嚗?

rm hello.py
git rm hello.py
git commit -m "remove hello.py"

alt tag

?虫?蝔桃?瘜?芷鈭?雿輻 git checkout ?臭誑頛???瑼?:

rm hello.py
git checkout -- hello.py

alt tag

?啣遣???蔥 ( merge ) ? branch

?刻牧????branch 銋?嚗?蝯血之摰嗡???敹萸�?

?虜?????憭批振?賣敺?master ??????branch ?箏嚗?敺? merge ??master嚗?

?箔?暻潸??獐? ? ?閬Ⅱ靽之摰園?臭蝙?冽??啁? master

雿輻 git branch ?誘?亦??桀????荔?

git branch

alt tag

擐??萄遣銝�???荔?bug1 ? ( ?迂?臭誑?其噶??)嚗敺?? bug1 ?嚗?

git branch bug1
git checkout bug1

git branch bug1 ?箏????蝔梁 bug1 ???荔?

git checkout bug1 ?箏??銝�??蝔梁 bug1 ???臬?銝�?

alt tag

隞乩??抵??誘嚗?嗆銝?銝�銵?隞?

git checkout -b bug1

(???之摰嗡????�撌? 隞乩??�?隞文隞亙翰????銝�???? ??cd - 璁艙銝�璅?exclamation:)

git checkout -

?� bug1 ?銝�脰?隞颱?靽格??嚗?

?嗅???撌乩??? ( 鋆?銝�銝?靽格隞颱??批捆敺?閮?雿輻 git add ?誘??git commit ?誘 ) ?蔥??master ?銝?

git checkout master
git merge bug1

alt tag

git checkout master ?箏??銝�??蝔梁 master ???臬?銝�?

git merge bug1 ?誘?冽?蔥 ( bug1? ) ????啁????( master ) 摨???

憒??虜?嚗?git merge ???航ㄐ???Fast-forward嚗?雿菟�漲?虜敹怒�?

?嗥銝瘥活?蔥?質敺??拍??箇 Fast-forward嚗?憭????箇銵? CONFLICT ??

憒???蔥 ( merge ) 摰?敺?撠勗隞亙??(?祆?) bug1 ?嚗?

git branch -d dev

alt tag

憒?閬??????◤?蔥???嚗隞乩蝙??git branch -D ??迂 撘瑁??芷 (?祆?)??

git branch -D dev

?????憭抵??芷 remote 蝡舐? branch 閰脫�獐颲血:question:

git push origin --delete {remote_branch}

鋆?嚗it branch 銋隞乩耨?孵?蝔梧??? commit id ?臭??霈?嚗蝙?冽瘜?敺陛?殷?

?臬???git-branch ?辣嚗蝙?冽瘜?銝?

git branch -m <name>

???b1 branch ???log 憒?嚗?

alt tag

?曉撠?b1 branch 靽格??b2 branch嚗?

alt tag

憒?雿?蝝啣?????log 瘥?嚗????log ??commit id ?臭??霈?嚗?

alt tag

雿輻?孵? commit id 撱箇? branch

???????單葫閰行???commit ???? ???隞亦?亙??commit id ?餃遣蝡???branch,

?寞?憒?,

git checkout -b new_branch <commit id>

?見撠望?靘雿?摰? commit id ?餃遣蝡銝�??branch.

?啣遣? branch 銝?push

?訾縑憭批振??? github 銝?賣??嚗?銝?嚗?憭???

alt tag

?????憒?撱箇???? 擐?嚗??????a�撐??

alt tag

????v1 ???荔?銝虫???銝?????g.py 銝虫? commit??

?乩?靘? *蝚砌?甈? git push ???? 雿??潛?隤斗?蝷?

隢蝙?其誑銝?隞斗??舀迤蝣箇?

git push --set-upstream origin v1

銋隞乩蝙??

git push -u origin v1

?游?閰喟敦隤芣??臬???https://git-scm.com/docs/git-push#git-push--u

alt tag

?乩?靘??臭誑?啁雯????( ?ㄐ??bitbucket ?嗡?蝭? ) 嚗???暹?? v1 鈭?

alt tag

憒??舐洵銝�甈∩蝙??git clone 嚗???曆??芣? master ? 嚗?

???????亦??垢??隞�暻澆??荔?

git branch -r
git branch --remote

--remote ??-r ?賢隞?

?身?垢????蝔梁 develop ???荔?

?�閬?checkout ?啗府?摨?撠勗隞乩?

git checkout develop

git switch

Youtube Tutorial - git switch ??git restore ?飛

隢?蝣箄??桀???git ?, ?湔?寞??臬???git ?湔.

??git 2.23 ???, 憓?鈭?git switch ??git restore, ???隞支蜓閬

閬皜??????? 銝餉??臭?隞? git checkout.

雿撖血隞交??git checkout = git switch + git restore.

摰?辣?臬???git-switch

git switch [<options>] (-c|-C) <new-branch> [<start-point>]

???唬??歇蝬??函? branch (憒?閰?branch 銝??典??誘?⊥?)

git switch <new-branch>

撱箇? new-branch 銝虫?????new-branch ?

git switch -c <new-branch>

-c --create

-C --force-create

靘 commit_id (?? N ??commit 暺? 撱箇? new-branch 銝虫?????new-branch ?

git switch -c <new-branch> <commit_id>
git switch -c <new-branch> HEAD~2

(???之摰嗡????�撌? 隞乩??�?隞文隞亙翰????銝�???? ??cd - 璁艙銝�璅?smile:)

git switch -

git restore

Youtube Tutorial - git switch ??git restore ?飛

隢?蝣箄??桀???git ?, ?湔?寞??臬???git ?湔.

??git 2.23 ???, 憓?鈭?git switch ??git restore, ???隞支蜓閬

閬皜??????? 銝餉??臭?隞? git checkout.

雿撖血隞交??git checkout = git switch + git restore.

摰?辣?臬???git-restore

隞乩??拙�?隞斗?詨???

git checkout <file>
git restore <file>

???桀?鞈?憭曉?函?瑼?

git restore .

???桀?鞈?憭曉?銝?撠暹 *.py ??冽?獢?

git restore '*.py'

憒?雿? git ?瘥??? 雿?閰脫??潛?�?隞支?隞亙?憟賢?瘝???smile:

alt tag

git restore --staged <file>

git pull

?虜?券?憪極雿?閬?push 銋?嚗????垢???嚗?

git pull

憒???蝒?閬?閫??蝒�?

??鋆?銝�銝?-C ?�??貊??�? 摰??�誨銵冽?摰?folder 頝臬?,

??????賭??喳? cd ?脣鞈?憭? ?�脰? pull, ????

撠勗??拙?雿輻摰?smile:

git [-C <path>] pull

??,

cd git_folder
git pull

?臭誑?湔蝪∪???

git -C git_folder pull

git fetch

?臭誑?陛?格??git pull = git fetch + git merge

?�?靘?銝?撐?? git fetch + git merge

alt tag

???撐?? git pull

alt tag

?見?臭??舀?璆?鈭?!!

憭???????--prune,

?�蜓閬???臬??remote ?⊥???branch,

?????歇蝬??垢??branch ?芷, 雿雿銵?git branch --remote,

?餅??潛雿????圈鈭?branch ????(雿??雯?????臬歇蝬◤蝘駁鈭?sweat:)

撣詨虜?? pull 蝡??極雿垢)????(憒?銝??閰梁??�遣霅啁?敶梁?隤芣?:smile:)

???停?臭誑?郊銝�銝璈??垢???? 雿輻隞乩???隞?

git fetch --prune

git rebase

隞�暻潭 rebase ??? git rebase 撠望?踹?憭? ( 瘝??儔 ) ??merge !!! ?????W撘萄?

鋆? :

ck = checkout

br = branch

st = status

cm = commit

?臭誑?芾?閮剖???

??

alt tag

??

alt tag

?? ???? 雿?甇∠??芰車??? 蝑?敺?憿荔????? !!

rebase ??蜓閬停?舐???????

?刻??之摰嗡?摰??嚗?隞交??湔撖行蝯血之摰嗥???

?內蝭?瘝?雿輻 rebase ??靘?

?桀??

alt tag

alt tag

隞乩?隤芣? : ?遣蝡?v1 branch嚗??add 敺? commit??

?身?曉??鈭?push 鈭?隞乩?璅⊥ pull 嚗撌勗?銝???commit

alt tag

隞乩?隤芣? : ?芸楛??master ?銝? t2.txt 嚗?銝虫?commit ( 璅⊥ pull )

?乩?靘?????master ?銝? v1 branch ? ?蔥嚗蒂銝?push

alt tag

雿??潛嚗*蝷箏靘??蒂銝?鈭殷?憒???

alt tag

蝷箇? 雿輻 rebase ??靘?

??隞賢?砌?銝�璅?

alt tag

alt tag

隞乩?隤芣? : ?遣蝡?v1 branch嚗??add 敺? commit??

?身?曉??鈭?push 鈭?隞乩?璅⊥ pull 嚗撌勗?銝???commit

alt tag

隞乩?隤芣? : ?芸楛??master ?銝? t2.txt 嚗?銝虫? commit ( 璅⊥ pull )

*撌桃?隞?

alt tag

隞乩?隤芣? : ??? v1 ?嚗敺蝙?其誑銝?隞?

git rebase master

alt tag

隞乩?隤芣? : ????master ?嚗蒂銝蝙??merge ?蔥 v1 ?嚗?敺 push

雿?~ ?臭??航??朣?瞍漁憭???

alt tag

git rebase 撠望撠?master ????commit ?亙?靘???銝撌勗??舐? commit??

隞乩?撠望 git rebase ??蝝嫘�?

git rebase interactive

撠???僑頛?銝�?港誑??git rebase 撠勗?航? commit log ?絲靘?頛嗾瘛刻�歇嚗?????潛嚗?

git rebase ??interactive 頞撥嚗?隞伐???撠曹?隞晶 git rebase ?撥憭批???:smirk:

隞乩???git rebase interactive ?臭誑雿輻??隞歹???隤芣??舀?敺?git 銝剛?鋆賢靘?嚗?蝑?憿舐內蝯血之摰嗥?嚗?

# Commands:
# p, pick = use commit
# r, reword = use commit, but edit the commit message
# e, edit = use commit, but stop for amending
# s, squash = use commit, but meld into previous commit
# f, fixup = like "squash", but discard this commit's log message
# x, exec = run command (the rest of the line) using shell
# d, drop = remove commit

憒?憭批振?唾??湧�脖?甇亦?鈭圾嚗??�?INTERACTIVE MODE嚗?

pick 瘝?暻澆末雓?嚗停雿輻?�?commit ?歇:smile:

reword

Youtube Tutorial - git rebase interactive - reword - PART 1

# Commands:
# p, pick = use commit
# r, reword = use commit, but edit the commit message

隞乩??箏??寧?隤芣?

If you just want to edit the commit message for a commit, replace the command "pick" with the command "reword".

隤芣?撌脩?敺?璆?嚗停?臬隞亦楊頛?commit message??

( 銝靽格 commit ?批捆嚗?撠望 files ?批捆 )

?身嚗?冽???銝�??git log ?舫�見嚗?

alt tag

commit id 2659f65 ??Typo嚗迤蝣箇? commit message ?府?? add c.py ??嚗?

?�隞亦?刻?靽格迤隞??�??格? commit id ??2659f65嚗?隞斤

git rebase -i <after-this-commit>

after-this-commit ?�隞�暻潭???question:

蝪∪隤迎?撠望閬?嗡???commit id ??銝�??

隞仿��?摮?隤迎??�??格? commit id ??2659f65嚗??誘?�???

git rebase -i f0a761d

alt tag

?見?府撠勗?皜?鈭?蝮賭?嚗?敺??豢??格? commit id ??銝�?停撠???

?嗡??? ENTER 銋?嚗??府???唬???

alt tag

A ?隞賢停?舀???靽格?璅?B ??停?航牧??( ?鞎潛策憭批振???梯正 )嚗?

?亥?嚗? i ?脣蝺刻摩璅∪?嚗敺??格??寞? r ? reword ?賢隞伐??亥?頛詨 :wq

alt tag

?亥??�??? ENTER嚗??歲?箔?甈∠?g?????雿停撠?commit 閮靽格??

甇?Ⅱ??撠? add c.py Typo 靽格??add c.py

alt tag

頛詨 :wq 銋?嚗? ENTER ( 摰? )

alt tag

?�???log 蝣箄?銝�銝? 憒???)嚗?蝣箔耨?寞???嚗???閮靽格??add c.py嚗?

alt tag

???�?寡??之摰嗆?銝�銝?撠望 commit id ?霈????寡???寞??箔?蝯血?雿?嚗?

靽格??

alt tag

靽格敺?

alt tag

蝪∪靘牧嚗停?舐??commit id 銋???commit id ?賣??寡? ( ??蝜 😅 )

??鋆?銝�銝??芾?雿鈭?rebase嚗停???圈?隡潔??Y???

alt tag

origin/master 撠望??蝡?( romote ) ??repo嚗??臬?雿牧雿?函? repo 撌脩???origin/master

銝?璅??嚗?隞伐?????憒?閬?push嚗?雿輻 git push --force-with-lease??

???航?犖??嚗???撣?靽格蝚砌???commit 閰脫�獐颲?:question:

???隞乩蝙?剁?

git rebase -i --root

edit

Youtube Tutorial - git rebase interactive - edit - PART 2

# Commands:
# p, pick = use commit
# e, edit = use commit, but stop for amending

隞乩??箏??寧?隤芣?

By replacing the command "pick" with the command "edit", you can tell git rebase to stop after applying that commit, so that you can edit the files and/or the commit message, amend the commit, and continue rebasing.

蝪∪隤迎?reword ?芸隞乩耨??commit message嚗�?edit 銝?臭誑靽格 commit message 嚗??臭誑靽格 files ?批捆??

????銝?撐??

alt tag

??敺?憿?add a.py -> add b.py -> add c.py -> add d.py 嚗?冽??喳 add c.py ??add d.py 銝剖????镼選?

銋停?航???add a.py -> add b.py -> add c.py -> add c1.py -> add d.py ?見??

憓?銝�?? add c1.py ??憓?撠勗隞乩蝙??edit 鈭?( 隞乩??停銝牧??獐閰喟敦鈭???亥??? )嚗?

?銵誑銝?隞?( ?�??格???a7ed6ff 嚗?隞仿隞?銝???commit id嚗?撠望 f0a761d )

git rebase -i f0a761d

?活?�? pick 靽格??e ? edit ( 憒???)

alt tag

?嗡??? ENTER 銋?嚗????唬???

alt tag

A ?隞賣?臭誑靽格 commit message嚗?

B ?隞賢??臬?雿牧?嗡?靽格 ( 皛輯雲 ) 摰嚗隞亙銵?git rebase --continue嚗?

A ?隞賣?????嚗??�?其??極??( 憓? c1.py )嚗?

擐?嚗??遣蝡???c1.py 瑼?嚗敺?git add c1.py嚗??commit 隞?( 憒???)

alt tag

???牧??嚗雿遛頞單?嚗?瑁? git rebase --continue嚗撌?

alt tag

? log 蝣箄?銝�銝?憭芰?鈭?:satisfied: ?????颱?

alt tag

squash

Youtube Tutorial - git rebase interactive - squash fixup - PART 3

# Commands:
# p, pick = use commit
# s, squash = use commit, but meld into previous commit

隞乩??箏??寧?隤芣?

 The suggested commit message for the folded commit is the concatenation of the commit messages of the first commit and of those with the "squash" command,

蝪∪隤迎?雿??閬?憭�?commit ?蔥????雿輻 squash 撠勗?鈭?( 隞乩??停銝牧??獐閰喟敦鈭???亥??? )嚗?

?活?璅閬? commit id fc45824 隞亙? commit id a7ed6ff ?蔥韏瑚? ( 憒???)

alt tag

?銵誑銝?隞?

git rebase -i f0a761d

?亥?雿??銝?嚗??? fc45824 ?�?cmmit ??pick 靽格??s ??squash

( 隞??蔥隞?????銋停??a7ed6ff )

alt tag

( 憒?雿??蔥憭�?commit嚗停憭�?寞? s ??squash, 瘜冽?, ??摨�?exclamation::exclamation: )

撠??? ENTER嚗??銝?

alt tag

????撌脩??蔥鈭�??commit嚗??停?臭誑頛詨?啁? commit message嚗?

???�撓??add c.py and c1.py

alt tag

?? ENTER ( ?? )

alt tag

?臭誑? log 蝣箄?銝�銝??�????拙�?commit ?蔥鈭?

alt tag

c.py 隞亙? c1.py ?賢??剁?隞?”?�???:satisfied:

alt tag

fixup

Youtube Tutorial - git rebase interactive - squash fixup - PART 3

# Commands:
# p, pick = use commit
# f, fixup = like "squash", but discard this commit's log message

隞乩??箏??寧?隤芣?

omits the commit messages of commits with the "fixup" command.

?嗅祕?�? squash 敺?嚗�虜憒??�?敹賜銝�??commit message 雿???commit ?摰對??�停?蝙??fixup嚗?

?格?嚗�??�閬宏??fc45824 ?�?commit ( 雿???commit ?摰?)

alt tag

?銵誑銝?隞?

git rebase -i f0a761d

撠?fc45824 ??pick 靽格??f ??fixup ( 憒???)

( 隞?蝘駁 fc45824 ?�?commit message 嚗?靽? commit ?摰?)

alt tag

?亥? ENTER嚗???rebase

alt tag

?臭誑? log 蝣箄?銝�銝??�蕭?乩? add c1.py ?�?commit

alt tag

雿 c.py 隞亙? c1.py ?賢???( ?芸蕭??commit message )嚗?

alt tag

??ㄐ嚗之摰嗅撖血隞交銝�??squash ??fixup ???虜憿撮嚗?

?芯???squash ?臭誑靽格 commit message??

蝪∪銝�暺??桃??唾?敹賜????commit message ??雿輻 fixup嚗?

?唾??蔥 commit 銝虫耨??commit message ??雿輻 squash??

exec

Youtube Tutorial - git rebase interactive - exec drop - PART 4

# Commands:
# p, pick = use commit
# x, exec = run command (the rest of the line) using shell

隞乩??箏??寧?隤芣?

You may want to check that your history editing did not break anything by running a test, or at least recompiling at intermediate points in history by using the "exec" command (shortcut "x")

?�??賣?瘥?撠嚗??隤芯?銝?蝪∪隤迎?撠望隞隞亦靘?check 雿?

rebase ?孵??臭??臬蔣?踹?湧? ( ??exec command 蝣箄? )??

?賭?憭芣? ❓ 瘝?靽?????憭拙?鈭?憭批???rabase ?游?嚗??蝣箄??�見??銋?嚗?

撠擃銝?蔣?選?銋停?臬隞亙?游????噶頝???test ?餌Ⅱ隤擃甇?虜 work??

??賭???:question: 銋???嚗??其???靘策憭批振??

alt tag

憒??????閬??葉??鈭?test ?餌Ⅱ靽?????蔣?踵擃?

( ????賣 pick嚗?撠望瘝??雿靘輯牧??憭批振隢銵???孵?:sweat_smile: )

alt tag

A ?隞?echo "test sucess" ?�?嗡??冽???嚗?

雿 B ??停???嚗??箸?祆???error ?�?隞歹?

?嗅??銵 shell ?隤斗?嚗???銝?嚗?雿耨甇??

憒????�??其? add c.py ?�?commit 銝???乩?靘? test error 鈭?

alt tag

?????隞乩耨甇??憿?靽格迤摰?銋?嚗??瑁? git rebase --continue??

alt tag

?�??賣??單?閰脫霈??駁?靽格??雿撌梁? test嚗Ⅱ靽?甇?虜??

drop

Youtube Tutorial - git rebase interactive - exec drop - PART 4

# Commands:
# p, pick = use commit
# d, drop = remove commit

隞乩??箏??寧?隤芣?

To drop a commit, replace the command "pick" with "drop", or just delete the matching line.

?�停蝪∪憭?嚗宏?日��?commit ( ? commit ?批捆 )嚗?

?身?�? log 憒?嚗?

alt tag

?活?璅蝘駁 f0a761d ??980bd9a ??1539219 ?? commit嚗?

?銵誑銝?隞?

git rebase -i 8f13aaa

撠?pick 靽格??d ??drop ( 憒???)

alt tag

??ENTER 銋?嚗???log 蝣箄?銝�銝?

alt tag

敺??隞亦?橘??�歇蝬???蝘駁 f0a761d ??980bd9a ??1539219 ?? commit嚗?

銝虫?銋???commit ?批捆銋鋡怎宏?支?嚗?拐? a.py ?歇??

git pull 鋆?

?Y隞晶摰? git fetch 隞亙? git rebase 銋?嚗銝???????鈭?git pull 憿???options ?

git pull [<options>] [<repository> [<refspec>?色�]

?游?閰喟敦?誘?臬???https://git-scm.com/docs/git-pull#_options??

?ㄐ蝪∪?渡?銝�銝?

git pull = git fetch + git merge
git pull --rebase = git fetch + git rebase

??git-rebase 銝剖歇蝬?憭批振鈭圾?唬蝙??git-rebase ?臭誑霈?code review ?犖

?絲靘?頛????�隞亙停雿輻 git pull --rebase ??( ???臭?閬???典凳??:smile: )??

???芋??git pull 隞亙? git pull --rebase ?榆?堆??噶??銵???瘜??甇仿??餃???

?�隞亙????喃?閫?憭???敹蛛?隢??誑銝????飛嚗?

Youtube Tutorial - git pull vs git pull --rebase

雿輻 git pull 敺?蝯?嚗ode review ?犖銝�摰蕃獢?( 憒???):triumph:

?????噶璅⊥銵?????雿??潛憒?雿輻 git pull ??銝�??commit (銋停?臭??寧? "fix conflict")??

alt tag

雿輻 git pull --rebase 敺?蝯?嚗ode review ?犖銵函內皞恍成 ( 憒???):innocent:

?????噶璅⊥銵?????雿??潛憒?雿輻 git pull --rebase 銝虫?????銝�璅??鈭???commit嚗?

???臬??箇?�蝙??git pull --rebase ??銵???靽桀末銵??摰嫣?敺?git add xxxx嚗????

?湔?瑁? git rebase --continue??

alt tag

?身隞予雿銵? git pull --rebase 銋?嚗?曉???? 😨嚗閬?瘨?

?湔?瑁? git rebase --abort ?喳?銋????�?

憿?鋆?撠?撌?

隤芣? --autostash,

銝�?砌?隤? 憒??�極雿銝�?? 蝒?唾??湔 git pull --rebase, ????commit,

瘚?憭抒???銝?見

git stash # 撠???孵?摮�脣 stash 銝?
git pull --rebase
git stash pop # 撠????孵?敺?stash 銝?pop ?箔?
# 憒???蝒??餉圾瘙箄?蝒?

雿???甈⊿閬銵�獐憭?隞文撖行?????sweat:

雿隞仿�?銝�???訾?閫?捱, 銋停??

git pull --rebase --autostash

隞乩??挾?誘?箸銝停?臬鼠雿銵???銝???銝脩??梯正,

憒???蝒? 撠勗?靽格迤銵??喳:smile:

git-cherry-pick

?蔣???湔?璆????葆憭批振????Youtube Tutorial - git-cherry-pick

git-cherry-pick ?�?隞文之摰嗅?賣?瘥???:confused:

瘝?靽??�?靘? 摰 ?牧??

git-cherry-pick - Apply the changes introduced by some existing commits

??摰隤芣??:question::question::question:

瘝?靽????身銝�??憓?( ?圾摰?雿停鈭圾鈭?git-cherry-pick ??? )嚗?

?身?曉 master ???log 憒???

alt tag

?嗅?????v1 ????log 憒???

alt tag

?曉????merge v1 ?銝剔? 14dee93 - add d.py ?�?commit

( ? 14dee93 ?�?commit 撖血憭芣?鈭??臬??箸?鈭???�閬��?commit )

?銝膩?車??嚗停敺?蝙??git-cherry-pick嚗?撠望隤芣??唾??嗡??銝剔??嗾??commit ?歇嚗?

銝?閬?剁??閰梯牧嚗停?舀?嗡??銝剔? commit ??雿輻??

鈭圾鈭??雿輻??嚗銝??�停靘祕??smirk:

擐?嚗??唾? v1 ?銝剔? 14dee93 - add d.py ?�?commit嚗?

?�隞交?????master ?嚗?銵?

git cherry-pick 14dee93

憒?雿閬?甈⊥敺????舫?靘??臬隞伐??湔雿輻蝛箇???喳

git cherry-pick 14dee93 xxxxxx xxxxxx xxxxxx xxxxx

憒?瘝?銵?嚗停???啣?銝?

alt tag

????銝?master ??log

alt tag

雿??潛?�??? v1 ?銝剔? 14dee93 - add d.py ?�?commit ?輸?靘?

雿輻鈭?雿?典???commit id ?餅 ab70429嚗��甇?虜???摰?閬?

??啗?蝞?smile:

?嗅祕嚗????git-cherry-pick 瘝??喳?銝剔??圈:satisfied:

??cherry-pick ????????啗?蝒????停??????蝒?蝭?嚗?

?身 master ??log 憒?

alt tag

v1 ?銝剔? log 憒?嚗??唾?摰? 3a2f29a - add c.py and print world ?�?commit

alt tag

v2 ?銝剔? log 憒?嚗??唾?摰? 553587b - add f.py?�?commit

alt tag

?乩?靘??停?? master嚗敺?cherry-pick ???commit嚗?

??????橘?摰?蝒?:fearful:

alt tag

雿輻 git status ??銝????嗅祕 A ????憒?閫??蝒?

alt tag

擐?嚗???撠?c.py 靽格迤敺??瑁? git add c.py嚗??? A ?隞?

?瑁? git cherry-pick --continue嚗停?�?頝喳銝�?楊頛航?蝒?

alt tag

頛詨摰?commit message 銋?嚗?頛詨 wq嚗停???唬???

alt tag

?�敺?????log嚗?

alt tag

?�????�???commit merge ?唳??? master ?銝?:kissing_smiling_eyes:

?喃?閫?憭?雿輻?寞?嚗?�??寞?隞? https://git-scm.com/docs/git-cherry-pick??

git revert

?身??commit history ??A1 -> A2 -> A3 -> A4 -> A5 -> A6

??冽閬? A4 ?�?commit , ????撠勗隞乩蝙??git revert 嚗?

??revert A6

git revert A6

??revert A5

git revert A5

??雿???函? commit history , 隞??瑞??�見

A1 -> A2 -> A3 -> A4 -> A5 -> A6 -> A6_revert -> A5_revert

?????嗅祕雿? commit 撠望??A4 ?�?蝵???

雿輻 git revert ?末??撠望?臭誑靽? commit history, ?砌?雿?敺?鈭?

銋隞亙 revert ???

憒?雿閬?revert ?�?啁? commit, ?芷?閬蝙??HEAD

git revert HEAD

閫?捱銵?

?券�脰??蔥????????憿舐內??銵?conflicts 嚗�??停敹???閫?捱銵?敺????

?虜???摰寞??銵? conflicts 嚗停?臭蝙??pull ?�?隞斤??�?

alt tag

隞敦?�撐??憒?雿輻pull?�?隞歹??鼠雿??芸? merge ( 憒?鋆∠? Auto-merging Hello.py )嚗?

?嗅??亥???CONFLICT ( content ) : Merge conflict in Hello.py 嚗?隤?Automatic merge failed嚗?

撠望?迄雿? Hello.py ?�?獢?銵?嚗敺?敹???銝閫?捱銵???

git status ?臭誑?迄?�?蝒??辣??

alt tag

??銵??辣?�?? Git ??<<<<<<<嚗?======嚗?>>>>>> 璅??箔????舐??批捆嚗??耨?孵??W???鈭歹?

alt tag

?虜?�???銝靽格銵? conflicts嚗敺??�?commit

git add Hello.py
git commit -m "conflict fixed"

?身隞予?�閬璉��?merge ?�府?獐? 嚗?

git merge --abort

??

git reset --hard HEAD

?臭誑???活??merge ? merge ?�?

git stash ?誘

敺??�??�迤?券??潔???????debug嚗敺??嗆?銝�???賡?閬??乩耨甇??

雿?????commit ?曉??瘜???寞瘝?蝢抬?鈭??芸?鈭???????stash

?�祕?函??誘撠望晷銝?港???

?�?摮??身?�鈭?A.py ??B.py ???獢?

alt tag

?嗅?嚗?函??嗆?銝�??bug 敹?擐砌?(蝡)??嚗?

雿嚗???銝?鈭??????縊~~~

?????臭誑?拍隞乩??誘

git stash

alt tag

??雿閬皜??芸楛?活??stash ???臭?暻潘???甇??隞�暻澆??? ?臭誑雿輻隞乩??誘

蝭?

git stash save "?閮餉圾"
git stash save -u "feature"

?隤芣?

-u | --include-untracked

-a | --all

alt tag

?乩?靘??臭誑雿輻 status ?誘嚗???曇?銋暹楊鈭?

alt tag

銝虫??臭誑雿輻銝???隞支?閫�??stash 鋆⊿?镼?

git stash list

alt tag

?嗅?雿??芸??啗圾瘙粹��?bug嚗ommit 摰?敺? ?臭誑?蝙?其????誘??stash ??靘???隞文???銋??芷 stash

git stash pop

?身隞予雿?敺???stash嚗??臭誑??嚗?銝?(?貉撌勗?甇∠??冽?)

git stash pop 0
git stash pop stash@{0}

alt tag

雿??潛???镼踹?靘?~

憒?雿??蝙??stash ??銋?嚗?撣??芷 stash 嚗隞乩蝙?其????誘

git stash apply

憒???雿隞亦?曉???嚗?stash 銝行??◤?芷

alt tag

憒?雿?舀閬?斗摮??臭誑雿輻銝???隞?

git stash clear

敺??隞亦?橘?stash 鋆⊿?镼輯◤?�?支?

alt tag

憒?雿銝?????stash嚗隞乩蝙??(?貉撌勗?甇∠??冽?)

git stash drop 0
git stash drop stash@{0}

git tag

Youtube Tutorial - git tag ?飛

?亦? tag

git tag

alt tag

???摮?

git tag -l "v1.*"

-l --list

git tag ??頛?蝝?蝐?lightweight tag) ???酉璅惜(annotated tag).

頛?蝝?蝐?lightweight tag)

憒??唾?撱箇?銝�??????蝐歹?隢?閬?摰?-a -s(GPG-signed) -m

git tag tag_name [commit_id]

憒??芯蝙??git tag tag_name , ????敺 Commit id,

???芸???tag ?曉?桀??��?Commit id 銝?

憿舐內閮餉圾

git show v1.1-light

?酉璅惜(annotated tag)

git tag -a v1.1 -m "version 1.1"

-a 撠望璅惜?迂 --annotate

-m 隞?”閰脫?蝐方牧??閮餉圾)

?冽?摰? commit 銝身 tag

git tag -a v1.2 -m "version 1.1" [commit_id]

憿舐內閮餉圾

git show v1.1

頛?蝝?蝐?lightweight tag) ???酉璅惜(annotated tag) ?榆?亙停?舀?西??游??敦蝭�,

?酉璅惜(annotated tag) 憭??游???閮?

頛?蝝?蝐?lightweight tag) 憒?

alt tag

?酉璅惜(annotated tag) 憒?

alt tag

?嗡??瑁? git push ?身?臭??? tag ?典 remote.

?�閬銵誑銝??誘, push tag ??remote 蝡?

git push origin [tagname]

銝�甈?push 敺? tags (撠????券銝 remote 蝡舐? tag ??push 銝.)

git push origin --tags

?嗅隞犖?瑁? git clone ??git fetch 撠勗隞交?圈�? tags.

蝘駁?砍 tag

git tag -d [tagname]

?芷 remote tag

git push --delete origin [tagname]

git show

銝�?砌?隤迎???其?靘??�?commit 靽格鈭鈭镼?

git show <commit ID>

alt tag

git show [<options>] [<object>?色�

?嗡??渲底蝝啁?隞晶嚗??�?https://git-scm.com/docs/git-show

git diff

隞乩??箏??寡牧??

 Show changes between commits, commit and working tree, etc

???嗾??摮?

瑼????脣?怠??� ( Stage )嚗?撠望?瑁? git add xxx 銋?嚗?

?臭誑??鈭鈭耨?對?

alt tag

銋隞亦? commits 銋??榆??

alt tag

?嗡??渲底蝝啁?隞晶嚗??�?https://git-scm.com/docs/git-diff

git grep

隞乩??箏??寡牧??

git-grep - Print lines matching a pattern

蝪∪隤迎?撠望?臭誑撟思??曉蝚血???pattern嚗???摮?????箏摰?

????hello ?�?pattern ??獢?????撠勗隞亙銵誑銝?隞?

git grep "hello"

alt tag

?*蝷箏閰?pattern ?典�?獢誑?畾萇?撘Ⅳ??啜�?

?嗡??渲底蝝啁?隞晶嚗??�?https://git-scm.com/docs/git-grep

git Submodule

?望?�摰寧?敺格?頛?嚗?隞交??血?撖思?銝�蝭?

git Submodule tutorial 📝

git Subtree

?望?�摰寧?敺格?頛?嚗?隞交??血?撖思?銝�蝭?

git subtree tutorial 📝

git ?嗡?閮剖?

?�歇蝬身摰? user.name 隞亙? user.email 嚗? Git 銝撖阡???憭閮剖??镼?

?????�?????瑼? ( ?辣憭?) ?曉 Git 撌乩??桅?銝哨?雿?銝?漱摰�?

?撖Ⅳ閮剖??蝺刻陌??IDE ?Y??箔??镼蹂?憿?嚗?

瘥活 git status ?賣??蝝???Untracked files 嚗�虜?死敺?暺......

??憿?Git 銋鼠?�???芾???Git 撌乩??�??桅?銝撱箔??畾? .gitignore ?辣 嚗?

?嗅???敹賜??隞?( 瑼? ) ?迂頛詨?脣嚗?Git 撠望??芸?敹賜???辣??

?嗥銝?閬撌勗??剖神 .gitignore ?辣嚗?GitHub 撌脩?撟急?????銝�鈭?隞?gitignore

.gitignore 瑼??湔?曉?桅?摨??喳

alt tag

.gitignore 瑼??澆?蝭?

alt tag

.gitignore (Temporarily and Permanently)

銝餉????急?(Temporarily) ??瘞訾?(Permanently) ?gnore嚗?

  • Temporarily ignore

?拙?雿輻??settings ??獢????????????賣??撌梁?閮剖?嚗?

雿��身摰敹憭批振?賡?閬?嚗�??停?臭誑?急??蕭?仿��?獢??寡???

?急?敹賜?�?獢?

git update-index --skip-worktree <file>

?W儔(Resume)?急?敹賜?�?獢?

git update-index --no-skip-worktree <file>
  • Permanently ignore

??鋆?銝�??憓??身隞予 file ?�?獢歇蝬◤ commit ??git 銝凋?嚗?

雿???? .gitignore嚗�見閰脫�獐颲?question:

憒?雿 .gitignore 銝剖???file嚗???暸??舀??◤ ignore:confused:

alt tag

????甇?Ⅱ??瘜?閰脫閬??瑁?撌脖??誘嚗?

git rm --cached <file>

?瑁?摰???commit ?喳 ( 瑼?銝?敺頂蝯曹??芷嚗?航??湔 git ??index ?歇 )

alt tag

???隞亙??岫?湔 file ?摰對?雿??潛摰??◤ ignore 鈭?smile:

git alias

???虜撣豢?畾?key ?舀?隞斗??航?銝絲靘?

憒??�? git st 撠梯”蝷?git status ??府??璉?!!

?�隞交??隞亥撌梯身摰?霈?Git 隞亙???git st = git status 憒????銝雿輻 git st 嚗身摰?銋?撠勗隞乩蝙?其???

git config --global alias.st status

alt tag

git config --global alias.br branch

alt tag

git config --global alias.ck checkout
git config --global alias.sw switch
git config --global alias.cm commit
git config --global alias.lg "log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --date=relative"

撠??a�?憭找葡霈?銝�????見隞亙??芷?閬銵?git lg ?喳嚗?

alt tag

?航?犖??嚗?�身摰??辣?典鋆∪?

?虜?雿?雿輻??銝?靘??�?餉雿輻? HJ嚗身摰??辣撠望???C:\Users\HJ 摨?嚗?

隞銝�?? ?梯??辣.gitconfig 嚗????店?澆?憒???

alt tag

銝?之摰嗆?瘝?瘜冽???--global ?�??賂?隞誨銵函??�?典???憒?隤芯?隞予?臬銵?

git config alias.stu status

隞?”?芣??刻府?桅?摨?????雿??

??��?隞�暻潛?g? 閰行銝�蝔格?憓??身雿?孵????冗摨?嚗閬蝙?函摰?靽∠拳??push嚗�隞?鞈?憭橘?

??璅?蝙?典?貊?靽∠拳嚗�???撠梢?撣賊?蝙?券�車?寞?摰???

?游?鞈?蝝啁??臭蝙?其誑銝隞斗??

man git-config

git ?湔

sudo add-apt-repository ppa:git-core/ppa
sudo apt-get update
sudo apt-get install git

alt tag

雿輻 Git 銝�甈?Push ?啣??????垢 ( remote )

????憭?github ??嚗�見?臭??臬停銝 work 鈭?雿?賣?隤芣?啁垢?? ?

雿?.....憭?隞賜?撠憟賭? !! ?�ㄐ隞晶憒?銝�甈?Push ?啣??????垢 ( remote )

?ㄐ??Bitbucket ?嗡?蝭?

?蝙?其??寞?隞斗??

git remote -v

alt tag

git remote ?�?隞斤??游?隤芣??臬????寞?隞?git-remote??

?亥??�蝙?其???隞斗憓???origin ??蝡?

git remote set-url --add origin <url>
git remote set-url --add origin git@github.com:twtrubiks/test2.git

alt tag

?�???git remote -v ?亦?銝�甈∴?雿??潛憭????啣???蝡?( remote )

alt tag

?�敺??? push

alt tag

隞敦???臭??臭?甈?push ?啣??????垢 ( remote )嚗?撣豢靘?!

GitHub

alt tag

Bitbucket

alt tag

P.S 閮剖?瑼鞈?憭曉?銝??梯?瑼?".git" 摨?嚗ㄐ?X?銝�??config

alt tag

鋆?撟曉�?git remote ??隞歹?隞??舀 rename 隞亙? remove 嚗?

?曉??remote 憒?嚗?

alt tag

霈????啣??remote嚗?瘜?銝?

git remote rename <old> <new>
git remote rename origin2 origin

?瑁?敺?雿??潛 remote ??鋡思耨?寞? origin 鈭?

alt tag

?乩?靘??岫閰?remove嚗?瘜?銝?

git remote remove <name>
git remote remove origin

???芷嚗??remote ?舐征??嚗?

alt tag

?乩?靘???閰行憓???remote嚗?隞文?銝?

git remote add [-t <branch>] [-m <master>] [-f] [--[no-]tags] [--mirror=<fetch|push>] <name> <url>
git remote add origin git@github.com:blue-rubiks/t11.git

alt tag

憒??�靽格 origin ??url嚗隞乩蝙??

git remote set-url origin git@blue.github.com:blue-rubiks/t11.git

alt tag

Multiple SSH Keys settings for different github account

Multiple SSH Keys settings for different github account

Git-Flow ?箸?飛隞亙?璁艙

Git-Flow ?箸?飛隞亙?璁艙

PR (Pull Request) ?飛

PR (Pull Request) ?飛

Linux 瘜冽?鈭?

???臬?憭批振隤芯?鈭?? windows 隞亙? linux 摨?雿輻 git ?航???啁???.

擐?, ??linux 摨??瑁?隞乩??誘

sudo chmod -R 777 folder

git ??隤??箸霈? 閬�獐??敹賜??? 隢銵誑銝?隞?,

git config core.fileMode false

銋?��??? Git ignore file mode (chmod) changes

?澆???

core.autocrlf

Windows 雿輻 Enter (Carriage Return 蝪∪神??CR) ????(Line Feed 蝪∪神??LF) ?????摰儔??,

??Mac ??Linux ?芯蝙?其???銵?(Line Feed 蝪∪神??LF) 摮?.

?�隞交?撠頝典像?啣?雿??箏?憿?

??windows 銝隞仿�見閮剖? ( 隞?” LF ?◤頧???CRLF)

git config --global core.autocrlf true

Linux ??Mac 蝟餌絞

git config --global core.autocrlf input

隞乩??見閮剖?, ? Windows 銝???CRLF嚗� Mac ??Linux 隞亙? repo 銝凋???LF.

憒?雿?湔楛?亦?鈭圾, ?臬????澆???core.autocrlf.

靽格 editor

git config --global core.editor "vim"

Reference

Donation

???賣?撌梁?蝛嗅???嚗???撟怠?唳嚗??喲??菜??店嚗迭餈???銝�?臬???laughing:

蝬?蝘?ECPAY ( 銝?閮餃?? )

alt tag

[韐??甈霄(http://bit.ly/2F7Jrha)

甇?撖?( ?�閮餃?? )

alt tag

[韐??甈霄(https://payment.opay.tw/Broadcaster/Donate/9E47FDEF85ABE383A0F5FC6A218606F8)

韐?

韐?

About

Git-Tutorials GIT基本使用教學:memo:

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published