gitlab鐨勫父瑙勬搷浣?杩滅▼鍙戝竷
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了gitlab鐨勫父瑙勬搷浣?杩滅▼鍙戝竷相关的知识,希望对你有一定的参考价值。
鏍囩锛?a href='http://www.mamicode.com/so/1/gitlab%e6%93%8d%e4%bd%9c' title='gitlab鎿嶄綔'>gitlab鎿嶄綔
gitlab鏄垜鑷繁鎼缓,鍙互鍙傝€?a href="http://blog.51cto.com/xiaozhagn/2122026" target="_blank">gitlab鎼缓
棣栧厛闇€瑕侀厤缃畐eb绔殑ssh瀵嗛挜鎵嶈兘鎿嶄綔杩滅▼锛岄厤缃繃绋嬪涓嬶細
鍦╨inux涓绘満涓婂厛鍋氬瘑閽ヨ璇?/p>
# ssh-keygen
璁よ瘉鎴愬姛鍚庯紝鎴戜滑鍙互鍙戠幇鍦ㄦ湰鍦扮洰褰?root/.ssh/涓嬩細鍙戠幇鏈塱d_rsa.pub鐨勬枃浠讹紝鎶婅鏂囦欢鐨勫唴瀹瑰鍒跺埌web绔紝鍋歴sh鐨勫瘑閽?/p>
[[email protected] ~]# ls /root/.ssh/ authorized_keys id_rsa id_rsa.pub known_hosts
娣诲姞杩囩▼濡備笅锛?/p>
鐧婚檰浣犵殑gitlab锛岀偣鍑籹etting锛屽涓嬪浘鎵€绀猴細
榧犳爣绉诲姩閽ュ寵鐨勫浘琛ㄧ偣鍑籗SH keys
鐒跺悗鎶婁綘闇€瑕侀獙璇佷富鏈虹殑id_rsa.pub鐨勪笢瑗垮鍒跺埌瀵嗛挜妗嗛噷闈紝娣诲姞瀹屾瘯鍚庡氨鍙互瀹屼簨浜嗭紝濡備笅鍥炬墍绀猴細
鍏嬮殕gitlab杩滅▼搴擄紙鍓嶆彁鏄凡缁忓垱寤哄畬浣犵殑椤圭洰锛?/p>
鎴戣繖閲屽湪鎼缓鐨勬椂鍊欐病鏈夊~鍐檌p锛屾墍浠ユ樉绀虹殑璺緞鏄痩ocalost杩欎釜闂涓嶆槸寰堝ぇ锛屾垜浠彲浠ョ洿鎺ョ敤IP鍏嬮殕灏卞ソ銆?/p>
# cd /learngit/ #git clone [email protected]:xiaozhang/xiaozhang.git
1銆佹帴涓嬫潵浜嗚В涓€涓媑it鐨勫父瑙勪娇鐢紝棣栧厛鎴戜滑浠庢湰鍦板彂甯冿紝鐒跺悗鍚屾鍒拌繙绋嬫湇鍔$銆?/p>
#鎴戜滑鍦ㄦ湰鍦板簱涓婂垱寤烘枃浠?/p>
[[email protected] xiaozhang]# pwd /learngit/xiaozhang [[email protected] xiaozhang]# echo 123 > xiaozhang.html
鏌ョ湅涓€涓嬬姸鎬?/p>
[[email protected] xiaozhang]# git status # On branch master # Untracked files: # (use "git add <file>..." to include in what will be committed) # #xiaozhang.html nothing added to commit but untracked files present (use "git add" to track)
鍙互鍙戠幇绯荤粺鍙綘鎶婃湰鍦版枃浠跺姞鍏ュ埌鏈湴搴撻噷闈紝鎴戜滑娣诲姞涓€涓?/p>
[[email protected] xiaozhang]# git add xiaozhang.html [[email protected] xiaozhang]# git status # On branch master # Changes to be committed: # (use "git reset HEAD <file>..." to unstage) # #new file: xiaozhang.html
鍙戠幇锛屾柊鏂囦欢宸茬粡娣诲姞鍒版湰鍦板垱搴撻噷闈簡锛屼絾鏄痝it鐨勭姸鎬佽繕娌℃竻闄わ紝杩欏氨闇€瑕佹垜浠笅涓€姝ョ殑鐢╟ommit鏉ユ墦鏍囩浜嗐€?/p>
[[email protected] xiaozhang]# git commit -m 'add xiaozhang.html' [master 491b8f9] add xiaozhang.html 1 file changed, 1 insertion(+) create mode 100644 xiaozhang.html
[[email protected] xiaozhang]# git status # On branch master # Your branch is ahead of 'origin/master' by 1 commit. # (use "git push" to publish your local commits) # nothing to commit, working directory clean
鍒颁簡杩欎竴姝ワ紝鍙戠幇浠诲姟鐘舵€佸凡缁忔竻闄や簡锛岀劧鍚庢垜璇曠殑鎺ㄩ€佸埌杩滅銆?/p>
[[email protected] xiaozhang]# git push warning: push.default is unset; its implicit value is changing in Git 2.0 from 'matching' to 'simple'. To squelch this message and maintain the current behavior after the default changes, use: git config --global push.default matching To squelch this message and adopt the new behavior now, use: git config --global push.default simple See 'git help config' and search for 'push.default' for further information. (the 'simple' mode was introduced in Git 1.7.11. Use the similar mode 'current' instead of 'simple' if you sometimes use older versions of Git) Counting objects: 4, done. Delta compression using up to 2 threads. Compressing objects: 100% (2/2), done. Writing objects: 100% (3/3), 317 bytes | 0 bytes/s, done. Total 3 (delta 0), reused 0 (delta 0) To [email protected]:xiaozhang/xiaozhang.git c0e86ec..491b8f9 master -> master
鍙戠幇宸茬粡鎴愬姛鐨勬帹閫佸埌杩滅銆傛煡鐪嬭繙绔痺eb鎴戜滑涔熷凡缁忓彲浠ュ彂鐜帮紝鏂囨。宸茬粡鎺ㄩ€佸埌杩滅浜嗐€?/p>
2銆佹簮绋嬬浠g爜琚洿鏂帮紝鑰屾湰鍦板簱娌℃湁鏈€鏂扮殑鏇存柊銆?/p>
鎴戜滑涔嬬洿鎺ュ湪杩滅▼鍒犻櫎鏂囦欢
杩滅▼绔凡缁忓仛浜嗘渶鏂扮殑淇敼浜嗭紝鑰屾湰鍦板簱鍙互鍙戠幇鏂囦欢杩樺湪
[[email protected] xiaozhang]# ls helloword.txt xiaozhang.html xiaozhang.txt
鍒拌繖鏃跺緢澶氫汉浼氭兂锛屾垜鍙互鎶婃湰鍦板簱鍐峱ush涓€閬嶅悧锛岃繖鏄笉琛岀殑锛岃繙绋嬬鏄笉鍏佽浣犺繖鏍峰仛鐨勶紝鍥犱负杩滅▼绔慨鏀圭殑灏辨槸鏈€鏂扮殑鎿嶄綔锛屼綘鐨勬湰鍦板簱宸茬粡杩囨椂浜嗭紝涓嶄俊鐨勮瘽鎴戜滑鏉ユ帹閫佷竴涓嬨€?/p>
鎴戜滑浼氬彂鐜板け璐ワ紝鎺ョ潃鎴戜滑鐪嬩竴涓嬫彁绀猴紝鍙戠幇瀹冨凡缁忔彁绀轰綘闇€瑕佹媺pull涓嬭浇鎵嶄綘姝e父鎿嶄綔銆?/p>
鎷夊彇锛?/p>
[[email protected] xiaozhang]# git pull remote: Counting objects: 2, done. remote: Compressing objects: 100% (2/2), done. remote: Total 2 (delta 1), reused 0 (delta 0) Unpacking objects: 100% (2/2), done. From 10.10.109.53:xiaozhang/xiaozhang 491b8f9..f588d76 master -> origin/master Updating 491b8f9..f588d76 Fast-forward xiaozhang.html | 1 - 1 file changed, 1 deletion(-) delete mode 100644 xiaozhang.html
鎴戜滑鍙戠幇鏈湴搴撳張涓庤繙绋嬪簱鍚屾鎴愬姛浜嗐€?/p>
3銆佸悇绉嶄俊鎭煡璇€佷互鍙婄増鏈洖婊氥€?/p>
锛?锛夋煡鐪嬫棩蹇椾俊鎭?/p>
[[email protected] xiaozhang]# git log --pretty=oneline f588d76af5d67278c05fdcda2701665896cd2cd9 鍒犻櫎 xiaozhang.html 491b8f9638a2640988fac5e4dbbd1355cc3777db add xiaozhang.html
鎴戜滑鍙戠幇閲岄潰鏈夎褰曠殑commit鐨勬搷浣滐紝濡傛灉浣犳兂鏇磋缁嗙殑鍙互杩欐牱
[[email protected] xiaozhang]# git reflog f588d76 [email protected]{0}: pull: Fast-forward 491b8f9 [email protected]{1}: commit: add xiaozhang.html c0e86ec [email protected]{2}: commit: add hellword 697749d [email protected]{3}: clone: from [email protected]:xiaozhang/xiaozhang.git
锛?锛夊垎鏀煡璇笌鍒涘缓锛屾垜浠彲浠ラ€氳繃branch 鈥揳鏌ョ湅鎵€鏈夌殑鍒嗘敮淇℃伅
[[email protected] xiaozhang]# git branch -a * master remotes/origin/HEAD -> origin/master remotes/origin/master
鎴戜滑鎺ョ潃鍒涘缓涓€涓垎鏀?/p>
[ [email protected] xiaozhang]# git checkout -b xiaozhang Switched to a new branch 'xiaozhang'
杩欎釜鍛戒护鐨勪綔鐢ㄥ氨鐩稿綋浜?/p>
#git branch xianzhang #鍒涘缓鍒嗘敮 #gir checkout xiaozhang #鎶妜iaozhang鍙樻垚涓诲垎鏀?/pre>锛?锛夌増鏈洖婊?/p>
鐗堟湰鍥炴粴涓昏灏辨槸閫氳繃鏃ュ織鏉ュ洖婊氫互鍓嶇殑鐗堟湰
#git reset --hard HEAD^ 鍥炴粴涓婁釜鐗堟湰 # git reset --hard HEAD^^ 鍥炴粴涓婁笂涓増鏈?/pre>鍏朵粬鐨勬垜浠€氳繃git reflog鏉ユ煡鐪嬬増鏈俊鎭紝浠讳綍鍥炴粴锛屽垪濡?/p>
# git reset --hard 锛?鍓嶉潰鐨勭紪鍙峰锛歠588d76af5d锛岃繖浜涚紪鍙峰彧闇€瑕佷笁鍥涗釜灏卞彲浠ュ疄鐜扮増鏈洖婊氫簡銆傦級鎬荤粨
涓汉瀵筭itlab鐨勬搷浣滈厤缃?甯屾湜鑳藉府鍒板ぇ瀹?/p>
以上是关于gitlab鐨勫父瑙勬搷浣?杩滅▼鍙戝竷的主要内容,如果未能解决你的问题,请参考以下文章
鎶€鏈彂甯?| Forge Viewer涓嶧orge API Node.js瀹㈡埛绔疭DK鐨凾ypeScript澹版槑鏂囦欢鍙戝竷锛?/h1>