git姣旇緝濂界悊瑙g殑璁板綍

浠ヤ笅鎵鏈夌殑鍛戒护鐨勫姛鑳借鏄庯紝閮介噰鐢ㄤ笂杩扮殑鏍囪鐨凙銆丅銆丆銆丏鐨勬柟寮忔潵闃愯堪銆

#鍒濆鍖
git init //鍒涘缓
git clone /path/to/repository //妫鍑
git config --global user.email "you@example.com" //閰嶇疆email
git config --global user.name "Name" //閰嶇疆鐢ㄦ埛鍚

#鎿嶄綔
git add <file> // 鏂囦欢娣诲姞锛孉 鈫 B
git add . // 鎵鏈夋枃浠舵坊鍔狅紝A 鈫 B

git commit -m "浠g爜鎻愪氦淇℃伅" //鏂囦欢鎻愪氦锛孊 鈫 C
git commit --amend //涓庝笂娆ommit鍚堝苟, *B 鈫 C

git push origin master //鎺ㄩ佽嚦master鍒嗘敮, C 鈫 D
git pull //鏇存柊鏈湴浠撳簱鑷虫渶鏂版敼鍔紝 D 鈫 A
git fetch //鎶撳彇杩滅▼浠撳簱鏇存柊锛 D 鈫 C

git log //鏌ョ湅鎻愪氦璁板綍
git status //鏌ョ湅淇敼鐘舵
git diff//鏌ョ湅璇︾粏淇敼鍐呭
git show//鏄剧ず鏌愭鎻愪氦鐨勫唴瀹

#鎾ら攢鎿嶄綔
git reset <file>//鏌愪釜鏂囦欢绱㈠紩浼氬洖婊氬埌鏈鍚庝竴娆℃彁浜わ紝 C 鈫 B
git reset//绱㈠紩浼氬洖婊氬埌鏈鍚庝竴娆℃彁浜わ紝 C 鈫 B
git reset --hard // 绱㈠紩浼氬洖婊氬埌鏈鍚庝竴娆℃彁浜わ紝 C 鈫 B 鈫 A

git checkout // 浠巌ndex澶嶅埗鍒皐orkspace锛 B 鈫 A
git checkout -- files // 鏂囦欢浠巌ndex澶嶅埗鍒皐orkspace锛 B 鈫 A
git checkout HEAD -- files // 鏂囦欢浠巐ocal repository澶嶅埗鍒皐orkspace锛 C 鈫 A

#鍒嗘敮鐩稿叧
git checkout -b branch_name //鍒涘缓鍚嶅彨鈥渂ranch_name鈥濈殑鍒嗘敮锛屽苟鍒囨崲杩囧幓
git checkout master //鍒囨崲鍥炰富鍒嗘敮
git branch -d branch_name // 鍒犻櫎鍚嶅彨鈥渂ranch_name鈥濈殑鍒嗘敮
git push origin branch_name //鎺ㄩ佸垎鏀埌杩滅浠撳簱
git merge branch_name // 鍚堝苟鍒嗘敮branch_name鍒板綋鍓嶅垎鏀(濡俶aster)
git rebase //琛嶅悎锛岀嚎鎬у寲鐨勮嚜鍔紝 D 鈫 A

#鍐茬獊澶勭悊
git diff //瀵规瘮workspace涓巌ndex
git diff HEAD //瀵逛簬workspace涓庢渶鍚庝竴娆ommit
git diff <source_branch> <target_branch> //瀵规瘮宸紓
git add <filename> //淇敼瀹屽啿绐侊紝闇瑕乤dd浠ユ爣璁板悎骞舵垚鍔

#鍏朵粬
gitk //寮鐏浘褰㈠寲git
git config color.ui true //褰╄壊鐨 git 杈撳嚭
git config format.pretty oneline //鏄剧ず鍘嗗彶璁板綍鏃讹紝姣忎釜鎻愪氦鐨勪俊鎭彧鏄剧ず涓琛
git add -i //浜や簰寮忔坊鍔犳枃浠跺埌鏆傚瓨鍖

Git浣跨敤瑙勮寖鎻愰啋

All posts

Other pages

鍙戣〃璇勮

鐢靛瓙閭欢鍦板潃涓嶄細琚叕寮銆 蹇呭~椤瑰凡鐢*鏍囨敞