{"id":272,"date":"2022-03-18T10:33:54","date_gmt":"2022-03-18T02:33:54","guid":{"rendered":"http:\/\/feel.name\/?p=272"},"modified":"2022-03-18T10:33:54","modified_gmt":"2022-03-18T02:33:54","slug":"gitlab%e5%ae%89%e8%a3%85%e4%bd%bf%e7%94%a8","status":"publish","type":"post","link":"http:\/\/feel.name\/?p=272","title":{"rendered":"Gitlab\u5b89\u88c5\u4f7f\u7528"},"content":{"rendered":"\n<p>git\u662f\u5e38\u7528\u7684\u7248\u672c\u7ba1\u7406\u5de5\u5177\uff0c\u5e9f\u8bdd\u5c11\u8bf4\u76f4\u63a5\u5f00\u5e72\u3002<\/p>\n\n\n\n<p>\u9996\u5148\u5b89\u88c5gitlab<\/p>\n\n\n\n<p>\u5b89\u88c5\u65b9\u5f0f\u5f88\u591a\u79cd\u3002<\/p>\n\n\n\n<p>\u6211\u4eec\u4ee5\u4e0b\u8f7dRPM\u5305\u7684\u65b9\u5f0f\u6765\u5b89\u88c5<\/p>\n\n\n\n<p>down\u4e0b\u6765\uff0c\u9996\u5148\u627e\u4e2a\u56fd\u5185\u7684yum\u6e90\u76f4\u63a5down\u5c31\u597d\u4e86<\/p>\n\n\n\n<p>yum -y install policycoreutils openssh-server openssh-clients postfix<\/p>\n\n\n\n<p>systemctl enable postfix &amp;&amp; systemctl start postfix<\/p>\n\n\n\n<p>wget https:\/\/mirrors.tuna.tsinghua.edu.cn\/gitlab-ce\/yum\/el7\/gitlab-ce-11.3.3-ce.0.el7.x86_64.rpm &#8211;no-check-certificate<\/p>\n\n\n\n<p>rpm -ivh gitlab-ce-11.3.3-ce.0.el7.x86_64.rpm<\/p>\n\n\n\n<p>yum install policycoreutils-python<\/p>\n\n\n\n<p>rpm -ivh gitlab-ce-11.3.3-ce.0.el7.x86_64.rpm<\/p>\n\n\n\n<p>\u5230\u8fd9\u6b65\u5df2\u7ecf\u5b89\u88c5\u597dGitlab\u4e86\u3002<\/p>\n\n\n\n<p>\u73b0\u5728\u4fee\u6539\u914d\u7f6e<\/p>\n\n\n\n<p>vi \/etc\/gitlab\/gitlab.rb<\/p>\n\n\n\n<p>\u4fee\u6539ip\u7aef\u53e3\u4f4d\u7f6e<\/p>\n\n\n\n<p>external_url &#8216;http:\/\/192.168.200.66:9999&#8217;<\/p>\n\n\n\n<p>\u670d\u52a1\u5668ip\u548c\u6307\u5b9a\u7684\u7aef\u53e3<\/p>\n\n\n\n<p>\u9632\u706b\u5899\u901a\u8fc79999\u7aef\u53e3<\/p>\n\n\n\n<p>firewall-<a rel=\"noreferrer noopener\" href=\"https:\/\/so.csdn.net\/so\/search?q=cmd&amp;spm=1001.2101.3001.7020\" target=\"_blank\">cmd<\/a>\u00a0&#8211;permanent &#8211;zone=public &#8211;add-port=9999\/tcp<\/p>\n\n\n\n<p>firewall-<a rel=\"noreferrer noopener\" href=\"https:\/\/so.csdn.net\/so\/search?q=cmd&amp;spm=1001.2101.3001.7020\" target=\"_blank\">cmd<\/a>\u00a0&#8211;reload<\/p>\n\n\n\n<p>\/sbin\/iptables -I INPUT -p tcp &#8211;dport 9999 -j ACCEPT<\/p>\n\n\n\n<p>\u542f\u7528Gitlab<\/p>\n\n\n\n<p>\u52a0\u8f7d\u914d\u7f6e<\/p>\n\n\n\n<p>gitlab-ctl reconfigure<\/p>\n\n\n\n<p>gitlab-ctl restart<\/p>\n\n\n\n<p>\u8fd9\u4e2a\u65f6\u5019\u7a0d\u5fae\u7b49\u5019\u4e86\u540e\u901a\u8fc7\u6d4f\u89c8\u5668\u6765\u6253\u5f00\u7f51\u5740\u4fee\u6539\u7ba1\u7406\u5bc6\u7801<\/p>\n\n\n\n<p>\u7136\u540e\u521b\u5efa\u9879\u76ee\uff0c\u7528\u6237\u7fa4\u7ec4\u8fd9\u4e9b\u4e86 \u521b\u5efa\u9879\u76ee\u7684\u65f6\u5019\u516c\u5f00\u79c1\u6709\u8fd9\u4e9b\u3002<\/p>\n\n\n\n<p>\u8fd9\u4e9b\u597d\u4e86\u540e\u53ef\u4ee5\u5728\u521b\u5efa\u7684\u540e\u9762\u53ef\u4ee5\u770b\u5230\u8fd9\u4e2agit\u7684\u5730\u5740\u4e86\u3002<\/p>\n\n\n\n<p>\u5730\u5740\u5982 http:\/\/192.168.200.66:9999\/root\/x-ko.git<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"repo-command-line-instructions\">Command line instructions<\/h3>\n\n\n\n<h5 class=\"wp-block-heading\">Git global setup<\/h5>\n\n\n\n<pre class=\"wp-block-preformatted\">git config --global user.name \"Administrator\"\ngit config --global user.email \"admin@example.com\"\n<\/pre>\n\n\n\n<h5 class=\"wp-block-heading\">Create a new repository<\/h5>\n\n\n\n<pre class=\"wp-block-preformatted\">git clone http:\/\/192.168.200.66:9999\/root\/x-ko.git\ncd x-ko\ntouch README.md\ngit add README.md\ngit commit -m \"add README\"\ngit push -u origin master<\/pre>\n\n\n\n<h5 class=\"wp-block-heading\">Existing folder<\/h5>\n\n\n\n<pre class=\"wp-block-preformatted\">cd existing_folder\ngit init\ngit remote add origin http:\/\/192.168.200.66:9999\/root\/x-ko.git\ngit add .\ngit commit -m \"Initial commit\"\ngit push -u origin master<\/pre>\n\n\n\n<h5 class=\"wp-block-heading\">Existing Git repository<\/h5>\n\n\n\n<pre class=\"wp-block-preformatted\">cd existing_repo\ngit remote rename origin old-origin\ngit remote add origin http:\/\/192.168.200.66:9999\/root\/x-ko.git\ngit push -u origin --all\ngit push -u origin --tags\n\n<\/pre>\n\n\n\n<p>git\u7684\u5e38\u7528\u547d\u4ee4<\/p>\n\n\n\n<p>git init # \u521d\u59cb\u5316\u672c\u5730git\u4ed3\u5e93\uff08\u521b\u5efa\u65b0\u4ed3\u5e93\uff09<br>git config &#8211;global user.name &#8220;xxx&#8221; # \u914d\u7f6e\u7528\u6237\u540d<br>git config &#8211;global user.email &#8220;xxx@xxx.com&#8221; # \u914d\u7f6e\u90ae\u4ef6<br>git config &#8211;global color.ui true # git status\u7b49\u547d\u4ee4\u81ea\u52a8\u7740\u8272<br>git config &#8211;global color.status auto<br>git config &#8211;global color.diff auto<br>git config &#8211;global color.branch auto<br>git config &#8211;global color.interactive auto<br>git clone git+ssh:\/\/git@192.168.53.168\/VT.git # clone\u8fdc\u7a0b\u4ed3\u5e93<br>git status # \u67e5\u770b\u5f53\u524d\u7248\u672c\u72b6\u6001\uff08\u662f\u5426\u4fee\u6539\uff09<br>git add xyz # \u6dfb\u52a0xyz\u6587\u4ef6\u81f3index<br>git add . # \u589e\u52a0\u5f53\u524d\u5b50\u76ee\u5f55\u4e0b\u6240\u6709\u66f4\u6539\u8fc7\u7684\u6587\u4ef6\u81f3index<br>git commit -m &#8216;xxx&#8217; # \u63d0\u4ea4<br>git commit &#8211;amend -m &#8216;xxx&#8217; # \u5408\u5e76\u4e0a\u4e00\u6b21\u63d0\u4ea4\uff08\u7528\u4e8e\u53cd\u590d\u4fee\u6539\uff09<br>git commit -am &#8216;xxx&#8217; # \u5c06add\u548ccommit\u5408\u4e3a\u4e00\u6b65<br>git rm xxx # \u5220\u9664index\u4e2d\u7684\u6587\u4ef6<br>git rm -r * # \u9012\u5f52\u5220\u9664<br>git log # \u663e\u793a\u63d0\u4ea4\u65e5\u5fd7<br>git log -1 # \u663e\u793a1\u884c\u65e5\u5fd7 -n\u4e3an\u884c<br>git log -5<br>git log &#8211;stat # \u663e\u793a\u63d0\u4ea4\u65e5\u5fd7\u53ca\u76f8\u5173\u53d8\u52a8\u6587\u4ef6<br>git log -p -m<br>git show dfb02e6e4f2f7b573337763e5c0013802e392818 # \u663e\u793a\u67d0\u4e2a\u63d0\u4ea4\u7684\u8be6\u7ec6\u5185\u5bb9<br>git show dfb02 # \u53ef\u53ea\u7528commitid\u7684\u524d\u51e0\u4f4d<br>git show HEAD # \u663e\u793aHEAD\u63d0\u4ea4\u65e5\u5fd7<br>git show HEAD^ # \u663e\u793aHEAD\u7684\u7236\uff08\u4e0a\u4e00\u4e2a\u7248\u672c\uff09\u7684\u63d0\u4ea4\u65e5\u5fd7 ^^\u4e3a\u4e0a\u4e24\u4e2a\u7248\u672c ^5\u4e3a\u4e0a5\u4e2a\u7248\u672c<br>git tag # \u663e\u793a\u5df2\u5b58\u5728\u7684tag<br>git tag -a v2.0 -m &#8216;xxx&#8217; # \u589e\u52a0v2.0\u7684tag<br>git show v2.0 # \u663e\u793av2.0\u7684\u65e5\u5fd7\u53ca\u8be6\u7ec6\u5185\u5bb9<br>git log v2.0 # \u663e\u793av2.0\u7684\u65e5\u5fd7<br>git diff # \u663e\u793a\u6240\u6709\u672a\u6dfb\u52a0\u81f3index\u7684\u53d8\u66f4<br>git diff &#8211;cached # \u663e\u793a\u6240\u6709\u5df2\u6dfb\u52a0index\u4f46\u8fd8\u672acommit\u7684\u53d8\u66f4<br>git diff HEAD^ # \u6bd4\u8f83\u4e0e\u4e0a\u4e00\u4e2a\u7248\u672c\u7684\u5dee\u5f02<br>git diff HEAD &#8212; .\/lib # \u6bd4\u8f83\u4e0eHEAD\u7248\u672clib\u76ee\u5f55\u7684\u5dee\u5f02<br>git diff origin\/master..master # \u6bd4\u8f83\u8fdc\u7a0b\u5206\u652fmaster\u4e0a\u6709\u672c\u5730\u5206\u652fmaster\u4e0a\u6ca1\u6709\u7684<br>git diff origin\/master..master &#8211;stat # \u53ea\u663e\u793a\u5dee\u5f02\u7684\u6587\u4ef6\uff0c\u4e0d\u663e\u793a\u5177\u4f53\u5185\u5bb9<br>git remote add origin git+ssh:\/\/git@192.168.53.168\/VT.git # \u589e\u52a0\u8fdc\u7a0b\u5b9a\u4e49\uff08\u7528\u4e8epush\/pull\/fetch\uff09<br>git branch # \u663e\u793a\u672c\u5730\u5206\u652f<br>git branch &#8211;contains 50089 # \u663e\u793a\u5305\u542b\u63d0\u4ea450089\u7684\u5206\u652f<br>git branch -a # \u663e\u793a\u6240\u6709\u5206\u652f<br>git branch -r # \u663e\u793a\u6240\u6709\u539f\u521b\u5206\u652f<br>git branch &#8211;merged # \u663e\u793a\u6240\u6709\u5df2\u5408\u5e76\u5230\u5f53\u524d\u5206\u652f\u7684\u5206\u652f<br>git branch &#8211;no-merged # \u663e\u793a\u6240\u6709\u672a\u5408\u5e76\u5230\u5f53\u524d\u5206\u652f\u7684\u5206\u652f<br>git branch -m master master_copy # \u672c\u5730\u5206\u652f\u6539\u540d<br>git checkout -b master_copy # \u4ece\u5f53\u524d\u5206\u652f\u521b\u5efa\u65b0\u5206\u652fmaster_copy\u5e76\u68c0\u51fa<br>git checkout -b master master_copy # \u4e0a\u9762\u7684\u5b8c\u6574\u7248<br>git checkout features\/performance # \u68c0\u51fa\u5df2\u5b58\u5728\u7684features\/performance\u5206\u652f<br>git checkout &#8211;track hotfixes\/BJVEP933 # \u68c0\u51fa\u8fdc\u7a0b\u5206\u652fhotfixes\/BJVEP933\u5e76\u521b\u5efa\u672c\u5730\u8ddf\u8e2a\u5206\u652f<br>git checkout v2.0 # \u68c0\u51fa\u7248\u672cv2.0<br>git checkout -b devel origin\/develop # \u4ece\u8fdc\u7a0b\u5206\u652fdevelop\u521b\u5efa\u65b0\u672c\u5730\u5206\u652fdevel\u5e76\u68c0\u51fa<br>git checkout &#8212; README # \u68c0\u51fahead\u7248\u672c\u7684README\u6587\u4ef6\uff08\u53ef\u7528\u4e8e\u4fee\u6539\u9519\u8bef\u56de\u9000\uff09<br>git merge origin\/master # \u5408\u5e76\u8fdc\u7a0bmaster\u5206\u652f\u81f3\u5f53\u524d\u5206\u652f<br>git cherry-pick ff44785404a8e # \u5408\u5e76\u63d0\u4ea4ff44785404a8e\u7684\u4fee\u6539<br>git push origin master # \u5c06\u5f53\u524d\u5206\u652fpush\u5230\u8fdc\u7a0bmaster\u5206\u652f<br>git push origin :hotfixes\/BJVEP933 # \u5220\u9664\u8fdc\u7a0b\u4ed3\u5e93\u7684hotfixes\/BJVEP933\u5206\u652f<br>git push &#8211;tags # \u628a\u6240\u6709tag\u63a8\u9001\u5230\u8fdc\u7a0b\u4ed3\u5e93<br>git fetch # \u83b7\u53d6\u6240\u6709\u8fdc\u7a0b\u5206\u652f\uff08\u4e0d\u66f4\u65b0\u672c\u5730\u5206\u652f\uff0c\u53e6\u9700merge\uff09<br>git fetch &#8211;prune # \u83b7\u53d6\u6240\u6709\u539f\u521b\u5206\u652f\u5e76\u6e05\u9664\u670d\u52a1\u5668\u4e0a\u5df2\u5220\u6389\u7684\u5206\u652f<br>git pull origin master # \u83b7\u53d6\u8fdc\u7a0b\u5206\u652fmaster\u5e76merge\u5230\u5f53\u524d\u5206\u652f<br>git mv README README2 # \u91cd\u547d\u540d\u6587\u4ef6README\u4e3aREADME2<br>git reset &#8211;hard HEAD # \u5c06\u5f53\u524d\u7248\u672c\u91cd\u7f6e\u4e3aHEAD\uff08\u901a\u5e38\u7528\u4e8emerge\u5931\u8d25\u56de\u9000\uff09<br>git rebase<br>git branch -d hotfixes\/BJVEP933 # \u5220\u9664\u5206\u652fhotfixes\/BJVEP933\uff08\u672c\u5206\u652f\u4fee\u6539\u5df2\u5408\u5e76\u5230\u5176\u4ed6\u5206\u652f\uff09<br>git branch -D hotfixes\/BJVEP933 # \u5f3a\u5236\u5220\u9664\u5206\u652fhotfixes\/BJVEP933<br>git ls-files # \u5217\u51fagit index\u5305\u542b\u7684\u6587\u4ef6<br>git show-branch # \u56fe\u793a\u5f53\u524d\u5206\u652f\u5386\u53f2<br>git show-branch &#8211;all # \u56fe\u793a\u6240\u6709\u5206\u652f\u5386\u53f2<br>git whatchanged # \u663e\u793a\u63d0\u4ea4\u5386\u53f2\u5bf9\u5e94\u7684\u6587\u4ef6\u4fee\u6539<br>git revert dfb02e6e4f2f7b573337763e5c0013802e392818 # \u64a4\u9500\u63d0\u4ea4dfb02e6e4f2f7b573337763e5c0013802e392818<br>git ls-tree HEAD # \u5185\u90e8\u547d\u4ee4\uff1a\u663e\u793a\u67d0\u4e2agit\u5bf9\u8c61<br>git rev-parse v2.0 # \u5185\u90e8\u547d\u4ee4\uff1a\u663e\u793a\u67d0\u4e2aref\u5bf9\u4e8e\u7684SHA1 HASH<br>git reflog # \u663e\u793a\u6240\u6709\u63d0\u4ea4\uff0c\u5305\u62ec\u5b64\u7acb\u8282\u70b9<br>git show HEAD@{5}<br>git show master@{yesterday} # \u663e\u793amaster\u5206\u652f\u6628\u5929\u7684\u72b6\u6001<br>git log &#8211;pretty=format:&#8217;%h %s&#8217; &#8211;graph # \u56fe\u793a\u63d0\u4ea4\u65e5\u5fd7<br>git show HEAD~3<br>git show -s &#8211;pretty=raw 2be7fcb476<br>git stash # \u6682\u5b58\u5f53\u524d\u4fee\u6539\uff0c\u5c06\u6240\u6709\u81f3\u4e3aHEAD\u72b6\u6001<br>git stash list # \u67e5\u770b\u6240\u6709\u6682\u5b58<br>git stash show -p stash@{0} # \u53c2\u8003\u7b2c\u4e00\u6b21\u6682\u5b58<br>git stash apply stash@{0} # \u5e94\u7528\u7b2c\u4e00\u6b21\u6682\u5b58<br>git grep &#8220;delete from&#8221; # \u6587\u4ef6\u4e2d\u641c\u7d22\u6587\u672c\u201cdelete from\u201d<br>git grep -e &#8216;#define&#8217; &#8211;and -e SORT_DIRENT<br>git gc<br>git fsck<\/p>\n\n\n\n<p>Git \u662f\u4e00\u4e2a\u5f88\u5f3a\u5927\u7684\u5206\u5e03\u5f0f\u7248\u672c\u63a7\u5236\u7cfb\u7edf\u3002\u5b83\u4e0d\u4f46\u9002\u7528\u4e8e\u7ba1\u7406\u5927\u578b\u5f00\u6e90\u8f6f\u4ef6\u7684\u6e90\u4ee3\u7801\uff0c\u7ba1\u7406\u79c1\u4eba\u7684\u6587\u6863\u548c\u6e90\u4ee3\u7801\u4e5f\u6709\u5f88\u591a\u4f18\u52bf\u3002<\/p>\n\n\n\n<p>Git\u5e38\u7528\u64cd\u4f5c\u547d\u4ee4\uff1a<\/p>\n\n\n\n<p>1) \u8fdc\u7a0b\u4ed3\u5e93\u76f8\u5173\u547d\u4ee4<\/p>\n\n\n\n<p>\u68c0\u51fa\u4ed3\u5e93\uff1a$ git clone git:\/\/github.com\/jquery\/jquery.git<\/p>\n\n\n\n<p>\u67e5\u770b\u8fdc\u7a0b\u4ed3\u5e93\uff1a$ git remote -v<\/p>\n\n\n\n<p>\u6dfb\u52a0\u8fdc\u7a0b\u4ed3\u5e93\uff1a$ git remote add [name] [url]<\/p>\n\n\n\n<p>\u5220\u9664\u8fdc\u7a0b\u4ed3\u5e93\uff1a$ git remote rm [name]<\/p>\n\n\n\n<p>\u4fee\u6539\u8fdc\u7a0b\u4ed3\u5e93\uff1a$ git remote set-url &#8211;push [name] [newUrl]<\/p>\n\n\n\n<p>\u62c9\u53d6\u8fdc\u7a0b\u4ed3\u5e93\uff1a$ git pull [remoteName] [localBranchName]<\/p>\n\n\n\n<p>\u63a8\u9001\u8fdc\u7a0b\u4ed3\u5e93\uff1a$ git push [remoteName] [localBranchName]<\/p>\n\n\n\n<p>*\u5982\u679c\u60f3\u628a\u672c\u5730\u7684\u67d0\u4e2a\u5206\u652ftest\u63d0\u4ea4\u5230\u8fdc\u7a0b\u4ed3\u5e93\uff0c\u5e76\u4f5c\u4e3a\u8fdc\u7a0b\u4ed3\u5e93\u7684master\u5206\u652f\uff0c\u6216\u8005\u4f5c\u4e3a\u53e6\u5916\u4e00\u4e2a\u540d\u53ebtest\u7684\u5206\u652f\uff0c\u5982\u4e0b\uff1a<\/p>\n\n\n\n<p>$git push origin test:master \/\/ \u63d0\u4ea4\u672c\u5730test\u5206\u652f\u4f5c\u4e3a\u8fdc\u7a0b\u7684master\u5206\u652f<\/p>\n\n\n\n<p>$git push origin test:test \/\/ \u63d0\u4ea4\u672c\u5730test\u5206\u652f\u4f5c\u4e3a\u8fdc\u7a0b\u7684test\u5206\u652f<\/p>\n\n\n\n<p>2\uff09\u5206\u652f(branch)\u64cd\u4f5c\u76f8\u5173\u547d\u4ee4<\/p>\n\n\n\n<p>\u67e5\u770b\u672c\u5730\u5206\u652f\uff1a$ git branch<\/p>\n\n\n\n<p>\u67e5\u770b\u8fdc\u7a0b\u5206\u652f\uff1a$ git branch -r<\/p>\n\n\n\n<p>\u521b\u5efa\u672c\u5730\u5206\u652f\uff1a$ git branch [name] &#8212;-\u6ce8\u610f\u65b0\u5206\u652f\u521b\u5efa\u540e\u4e0d\u4f1a\u81ea\u52a8\u5207\u6362\u4e3a\u5f53\u524d\u5206\u652f<\/p>\n\n\n\n<p>\u5207\u6362\u5206\u652f\uff1a$ git checkout [name]<\/p>\n\n\n\n<p>\u521b\u5efa\u65b0\u5206\u652f\u5e76\u7acb\u5373\u5207\u6362\u5230\u65b0\u5206\u652f\uff1a$ git checkout -b [name]<\/p>\n\n\n\n<p>\u5220\u9664\u5206\u652f\uff1a$ git branch -d [name] &#8212;- -d\u9009\u9879\u53ea\u80fd\u5220\u9664\u5df2\u7ecf\u53c2\u4e0e\u4e86\u5408\u5e76\u7684\u5206\u652f\uff0c\u5bf9\u4e8e\u672a\u6709\u5408\u5e76\u7684\u5206\u652f\u662f\u65e0\u6cd5\u5220\u9664\u7684\u3002\u5982\u679c\u60f3\u5f3a\u5236\u5220\u9664\u4e00\u4e2a\u5206\u652f\uff0c\u53ef\u4ee5\u4f7f\u7528-D\u9009\u9879<\/p>\n\n\n\n<p>\u5408\u5e76\u5206\u652f\uff1a$ git merge [name] &#8212;-\u5c06\u540d\u79f0\u4e3a[name]\u7684\u5206\u652f\u4e0e\u5f53\u524d\u5206\u652f\u5408\u5e76<\/p>\n\n\n\n<p>\u521b\u5efa\u8fdc\u7a0b\u5206\u652f(\u672c\u5730\u5206\u652fpush\u5230\u8fdc\u7a0b)\uff1a$ git push origin [name]<\/p>\n\n\n\n<p>\u5220\u9664\u8fdc\u7a0b\u5206\u652f\uff1a$ git push origin :heads\/[name] \u6216 $ gitpush origin :[name]<\/p>\n\n\n\n<p>*\u521b\u5efa\u7a7a\u7684\u5206\u652f\uff1a(\u6267\u884c\u547d\u4ee4\u4e4b\u524d\u8bb0\u5f97\u5148\u63d0\u4ea4\u4f60\u5f53\u524d\u5206\u652f\u7684\u4fee\u6539\uff0c\u5426\u5219\u4f1a\u88ab\u5f3a\u5236\u5220\u5e72\u51c0\u6ca1\u5f97\u540e\u6094)<\/p>\n\n\n\n<p>$git symbolic-ref HEAD refs\/heads\/[name]<\/p>\n\n\n\n<p>$rm .git\/index<\/p>\n\n\n\n<p>$git clean -fdx<\/p>\n\n\n\n<p>3\uff09\u7248\u672c(tag)\u64cd\u4f5c\u76f8\u5173\u547d\u4ee4<\/p>\n\n\n\n<p>\u67e5\u770b\u7248\u672c\uff1a$ git tag<\/p>\n\n\n\n<p>\u521b\u5efa\u7248\u672c\uff1a$ git tag [name]<\/p>\n\n\n\n<p>\u5220\u9664\u7248\u672c\uff1a$ git tag -d [name]<\/p>\n\n\n\n<p>\u67e5\u770b\u8fdc\u7a0b\u7248\u672c\uff1a$ git tag -r<\/p>\n\n\n\n<p>\u521b\u5efa\u8fdc\u7a0b\u7248\u672c(\u672c\u5730\u7248\u672cpush\u5230\u8fdc\u7a0b)\uff1a$ git push origin [name]<\/p>\n\n\n\n<p>\u5220\u9664\u8fdc\u7a0b\u7248\u672c\uff1a$ git push origin :refs\/tags\/[name]<\/p>\n\n\n\n<p>\u5408\u5e76\u8fdc\u7a0b\u4ed3\u5e93\u7684tag\u5230\u672c\u5730\uff1a$ git pull origin &#8211;tags<\/p>\n\n\n\n<p>\u4e0a\u4f20\u672c\u5730tag\u5230\u8fdc\u7a0b\u4ed3\u5e93\uff1a$ git push origin &#8211;tags<\/p>\n\n\n\n<p>\u521b\u5efa\u5e26\u6ce8\u91ca\u7684tag\uff1a$ git tag -a [name] -m &#8216;yourMessage&#8217;<\/p>\n\n\n\n<p>4) \u5b50\u6a21\u5757(submodule)\u76f8\u5173\u64cd\u4f5c\u547d\u4ee4<\/p>\n\n\n\n<p>\u6dfb\u52a0\u5b50\u6a21\u5757\uff1a$ git submodule add [url] [path]<\/p>\n\n\n\n<p>\u5982\uff1a$git submodule add git:\/\/github.com\/soberh\/ui-libs.git src\/main\/webapp\/ui-libs<\/p>\n\n\n\n<p>\u521d\u59cb\u5316\u5b50\u6a21\u5757\uff1a$ git submodule init &#8212;-\u53ea\u5728\u9996\u6b21\u68c0\u51fa\u4ed3\u5e93\u65f6\u8fd0\u884c\u4e00\u6b21\u5c31\u884c<\/p>\n\n\n\n<p>\u66f4\u65b0\u5b50\u6a21\u5757\uff1a$ git submodule update &#8212;-\u6bcf\u6b21\u66f4\u65b0\u6216\u5207\u6362\u5206\u652f\u540e\u90fd\u9700\u8981\u8fd0\u884c\u4e00\u4e0b<\/p>\n\n\n\n<p>\u5220\u9664\u5b50\u6a21\u5757\uff1a\uff08\u52064\u6b65\u8d70\u54e6\uff09<\/p>\n\n\n\n<p>1) $ git rm &#8211;cached [path]<\/p>\n\n\n\n<p>2) \u7f16\u8f91\u201c.gitmodules\u201d\u6587\u4ef6\uff0c\u5c06\u5b50\u6a21\u5757\u7684\u76f8\u5173\u914d\u7f6e\u8282\u70b9\u5220\u9664\u6389<\/p>\n\n\n\n<p>3) \u7f16\u8f91\u201c .git\/config\u201d\u6587\u4ef6\uff0c\u5c06\u5b50\u6a21\u5757\u7684\u76f8\u5173\u914d\u7f6e\u8282\u70b9\u5220\u9664\u6389<\/p>\n\n\n\n<p>4) \u624b\u52a8\u5220\u9664\u5b50\u6a21\u5757\u6b8b\u7559\u7684\u76ee\u5f55<\/p>\n\n\n\n<p>5\uff09\u5ffd\u7565\u4e00\u4e9b\u6587\u4ef6\u3001\u6587\u4ef6\u5939\u4e0d\u63d0\u4ea4<\/p>\n\n\n\n<p>\u5728\u4ed3\u5e93\u6839\u76ee\u5f55\u4e0b\u521b\u5efa\u540d\u79f0\u4e3a\u201c.gitignore\u201d\u7684\u6587\u4ef6\uff0c\u5199\u5165\u4e0d\u9700\u8981\u7684\u6587\u4ef6\u5939\u540d\u6216\u6587\u4ef6\uff0c\u6bcf\u4e2a\u5143\u7d20\u5360\u4e00\u884c\u5373\u53ef\uff0c\u5982<\/p>\n\n\n\n<p>target<\/p>\n\n\n\n<p>bin<\/p>\n\n\n\n<p>*.db<\/p>\n\n\n\n<p>=====================<\/p>\n\n\n\n<p>Git \u5e38\u7528\u547d\u4ee4<\/p>\n\n\n\n<p>git branch \u67e5\u770b\u672c\u5730\u6240\u6709\u5206\u652f<br>git status \u67e5\u770b\u5f53\u524d\u72b6\u6001<br>git commit \u63d0\u4ea4<br>git branch -a \u67e5\u770b\u6240\u6709\u7684\u5206\u652f<br>git branch -r \u67e5\u770b\u672c\u5730\u6240\u6709\u5206\u652f<br>git commit -am &#8220;init&#8221; \u63d0\u4ea4\u5e76\u4e14\u52a0\u6ce8\u91ca<br>git remote add origin git@192.168.1.119:ndshow<br>git push origin master \u5c06\u6587\u4ef6\u7ed9\u63a8\u5230\u670d\u52a1\u5668\u4e0a<br>git remote show origin \u663e\u793a\u8fdc\u7a0b\u5e93origin\u91cc\u7684\u8d44\u6e90<br>git push origin master:develop<br>git push origin master:hb-dev \u5c06\u672c\u5730\u5e93\u4e0e\u670d\u52a1\u5668\u4e0a\u7684\u5e93\u8fdb\u884c\u5173\u8054<br>git checkout &#8211;track origin\/dev \u5207\u6362\u5230\u8fdc\u7a0bdev\u5206\u652f<br>git branch -D master develop \u5220\u9664\u672c\u5730\u5e93develop<br>git checkout -b dev \u5efa\u7acb\u4e00\u4e2a\u65b0\u7684\u672c\u5730\u5206\u652fdev<br>git merge origin\/dev \u5c06\u5206\u652fdev\u4e0e\u5f53\u524d\u5206\u652f\u8fdb\u884c\u5408\u5e76<br>git checkout dev \u5207\u6362\u5230\u672c\u5730dev\u5206\u652f<br>git remote show \u67e5\u770b\u8fdc\u7a0b\u5e93<br>git add .<br>git rm \u6587\u4ef6\u540d(\u5305\u62ec\u8def\u5f84) \u4ecegit\u4e2d\u5220\u9664\u6307\u5b9a\u6587\u4ef6<br>git clone git:\/\/github.com\/schacon\/grit.git \u4ece\u670d\u52a1\u5668\u4e0a\u5c06\u4ee3\u7801\u7ed9\u62c9\u4e0b\u6765<br>git config &#8211;list \u770b\u6240\u6709\u7528\u6237<br>git ls-files \u770b\u5df2\u7ecf\u88ab\u63d0\u4ea4\u7684<br>git rm [file name] \u5220\u9664\u4e00\u4e2a\u6587\u4ef6<br>git commit -a \u63d0\u4ea4\u5f53\u524drepos\u7684\u6240\u6709\u7684\u6539\u53d8<br>git add [file name] \u6dfb\u52a0\u4e00\u4e2a\u6587\u4ef6\u5230git index<br>git commit -v \u5f53\u4f60\u7528\uff0dv\u53c2\u6570\u7684\u65f6\u5019\u53ef\u4ee5\u770bcommit\u7684\u5dee\u5f02<br>git commit -m &#8220;This is the message describing the commit&#8221; \u6dfb\u52a0commit\u4fe1\u606f<br>git commit -a -a\u662f\u4ee3\u8868add\uff0c\u628a\u6240\u6709\u7684change\u52a0\u5230git index\u91cc\u7136\u540e\u518dcommit<br>git commit -a -v \u4e00\u822c\u63d0\u4ea4\u547d\u4ee4<br>git log \u770b\u4f60commit\u7684\u65e5\u5fd7<br>git diff \u67e5\u770b\u5c1a\u672a\u6682\u5b58\u7684\u66f4\u65b0<br>git rm a.a \u79fb\u9664\u6587\u4ef6(\u4ece\u6682\u5b58\u533a\u548c\u5de5\u4f5c\u533a\u4e2d\u5220\u9664)<br>git rm &#8211;cached a.a \u79fb\u9664\u6587\u4ef6(\u53ea\u4ece\u6682\u5b58\u533a\u4e2d\u5220\u9664)<br>git commit -m &#8220;remove&#8221; \u79fb\u9664\u6587\u4ef6(\u4eceGit\u4e2d\u5220\u9664)<br>git rm -f a.a \u5f3a\u884c\u79fb\u9664\u4fee\u6539\u540e\u6587\u4ef6(\u4ece\u6682\u5b58\u533a\u548c\u5de5\u4f5c\u533a\u4e2d\u5220\u9664)<br>git diff &#8211;cached \u6216 $ git diff &#8211;staged \u67e5\u770b\u5c1a\u672a\u63d0\u4ea4\u7684\u66f4\u65b0<br>git stash push \u5c06\u6587\u4ef6\u7ed9push\u5230\u4e00\u4e2a\u4e34\u65f6\u7a7a\u95f4\u4e2d<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">git stash pop \u5c06\u6587\u4ef6\u4ece\u4e34\u65f6\u7a7a\u95f4pop\u4e0b\u6765<\/h2>\n\n\n\n<p>git remote add origin git@github.com:username\/Hello-World.git<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">git push origin master \u5c06\u672c\u5730\u9879\u76ee\u7ed9\u63d0\u4ea4\u5230\u670d\u52a1\u5668\u4e2d<\/h2>\n\n\n\n<h2 class=\"wp-block-heading\">git pull \u672c\u5730\u4e0e\u670d\u52a1\u5668\u7aef\u540c\u6b65<\/h2>\n\n\n\n<p>git push (\u8fdc\u7a0b\u4ed3\u5e93\u540d) (\u5206\u652f\u540d) \u5c06\u672c\u5730\u5206\u652f\u63a8\u9001\u5230\u670d\u52a1\u5668\u4e0a\u53bb\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">git push origin serverfix:awesomebranch<\/h2>\n\n\n\n<p>git fetch \u76f8\u5f53\u4e8e\u662f\u4ece\u8fdc\u7a0b\u83b7\u53d6\u6700\u65b0\u7248\u672c\u5230\u672c\u5730\uff0c\u4e0d\u4f1a\u81ea\u52a8merge<br>git commit -a -m &#8220;log_message&#8221; (-a\u662f\u63d0\u4ea4\u6240\u6709\u6539\u52a8\uff0c-m\u662f\u52a0\u5165log\u4fe1\u606f) \u672c\u5730\u4fee\u6539\u540c\u6b65\u81f3\u670d\u52a1\u5668\u7aef \uff1a<br>git branch branch_0.1 master \u4ece\u4e3b\u5206\u652fmaster\u521b\u5efabranch_0.1\u5206\u652f<br>git branch -m branch_0.1 branch_1.0 \u5c06branch_0.1\u91cd\u547d\u540d\u4e3abranch_1.0<br>git checkout branch_1.0\/master \u5207\u6362\u5230branch_1.0\/master\u5206\u652f<br>du -hs<\/p>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<p>mkdir WebApp<br>cd WebApp<br>git init<br>touch README<br>git add README<br>git commit -m &#8216;first commit&#8217;<br>git remote add origin git@github.com:daixu\/WebApp.git<br>git push -u origin master<br><\/p>\n\n\n\n<figure class=\"wp-block-image size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/feel.name\/wp-content\/uploads\/2022\/03\/20180620113451746-570x1024.png\" alt=\"\" class=\"wp-image-273\" width=\"838\" height=\"1506\" srcset=\"http:\/\/feel.name\/wp-content\/uploads\/2022\/03\/20180620113451746-570x1024.png 570w, http:\/\/feel.name\/wp-content\/uploads\/2022\/03\/20180620113451746-167x300.png 167w, http:\/\/feel.name\/wp-content\/uploads\/2022\/03\/20180620113451746-768x1381.png 768w, http:\/\/feel.name\/wp-content\/uploads\/2022\/03\/20180620113451746-854x1536.png 854w, http:\/\/feel.name\/wp-content\/uploads\/2022\/03\/20180620113451746-1139x2048.png 1139w, http:\/\/feel.name\/wp-content\/uploads\/2022\/03\/20180620113451746.png 1759w\" sizes=\"auto, (max-width: 838px) 100vw, 838px\" \/><\/figure>\n","protected":false},"excerpt":{"rendered":"<p>git\u662f\u5e38\u7528\u7684\u7248\u672c\u7ba1\u7406\u5de5\u5177\uff0c\u5e9f\u8bdd\u5c11\u8bf4\u76f4\u63a5\u5f00\u5e72\u3002 \u9996\u5148\u5b89\u88c5gitlab \u5b89\u88c5\u65b9\u5f0f\u5f88\u591a\u79cd\u3002 \u6211\u4eec\u4ee5\u4e0b\u8f7dRPM\u5305\u7684\u65b9&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[],"class_list":["post-272","post","type-post","status-publish","format-standard","hentry","category-linux"],"_links":{"self":[{"href":"http:\/\/feel.name\/index.php?rest_route=\/wp\/v2\/posts\/272","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/feel.name\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/feel.name\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/feel.name\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/feel.name\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=272"}],"version-history":[{"count":1,"href":"http:\/\/feel.name\/index.php?rest_route=\/wp\/v2\/posts\/272\/revisions"}],"predecessor-version":[{"id":274,"href":"http:\/\/feel.name\/index.php?rest_route=\/wp\/v2\/posts\/272\/revisions\/274"}],"wp:attachment":[{"href":"http:\/\/feel.name\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=272"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/feel.name\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=272"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/feel.name\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=272"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}