{"id":3223,"date":"2012-07-13T22:36:40","date_gmt":"2012-07-13T14:36:40","guid":{"rendered":"http:\/\/jpuyy.com\/?p=3223"},"modified":"2015-03-12T16:48:00","modified_gmt":"2015-03-12T08:48:00","slug":"git-howto-newbie","status":"publish","type":"post","link":"https:\/\/jpuyy.com\/?p=3223","title":{"rendered":"git\u5b66\u4e60\u7b14\u8bb0\u521d\u7ea7"},"content":{"rendered":"<p>ubuntu\u4e0b\u5b89\u88c5git<\/p>\n<pre>sudo apt-get install git git-core<\/pre>\n<p>\u6216\u8005\u5230\u65b0\u7acb\u5f97\u8f6f\u4ef6\u5305\u91cc\u9762 \u8f93\u5165 git \u5b89\u88c5\u3002<\/p>\n<p>\u5728\u672c\u5730\u4f7f\u7528git<\/p>\n<pre>git init\r\ngit add .\r\ngit commit -m 'project init'<\/pre>\n<p>\u5728\u5e93\u7684\u76ee\u5f55\u4e0b<\/p>\n<pre>git add . \u00a0 \u00a0 \uff03\u5b58\u50a8\u5230\u672c\u5730\r\ngit commit -m 'message' \u00a0 \u00a0#\u5b58\u50a8\u65f6\u7684\u6807\u8bb0\uff08message\u662f\u8bf4\u660e\u6587\u5b57\uff09\r\ngit pull \u00a0 #\u4e0b\u8f7d\u670d\u52a1\u5668\u4ee3\u7801\r\ngit push \u00a0 #\u4e0a\u4f20\u4ee3\u7801\u81f3github<\/pre>\n<p>\u53ea\u68c0\u51fa\u6700\u8fd1\u4e00\u6b21\u63d0\u4ea4\u7684commit<\/p>\n<pre>git clone git@bitbucket.org:jpuyy\/forge.jpuyy.com.git --depth=1<\/pre>\n<p>\u5df2\u7ecf\u5199\u4e86\u4e00\u4e9b\u4ee3\u7801\u4e4b\u540e\u60f3\u8981\u628a\u4ee3\u7801\u653e\u5165\u5230git\u5e93\u91cc\uff0c\u5148\u653e\u5230\u672c\u5730\uff0c\u518d\u63a8\u5230bitbucket\u4ee3\u7801\u4ed3\u5e93\u91cc<\/p>\n<pre>cd \/path\/to\/my\/repo\r\ngit init\r\ngit add .\r\ngit commit -m 'project init'\r\ngit remote add origin ssh:\/\/git@bitbucket.org\/jpuyy\/nginx.conf.git \r\ngit push -u origin --all # pushes up the repo and its refs for the first time \r\ngit push -u origin --tags # pushes up any tags<\/pre>\n<p>git\u521a\u521b\u5efa\u7684\u5e93\u63d0\u4ea4\u65f6\u63d0\u793a<\/p>\n<pre>\u279c jpuyy-shells git:(master) git push\r\nNo refs in common and none specified; doing nothing.\r\nPerhaps you should specify a branch such as 'master'.\r\nfatal: The remote end hung up unexpectedly\r\nEverything up-to-date\r\n<\/pre>\n<p>\u9700\u8981\u521b\u5efa\u4e00\u4e2amaster\u5206\u652f<\/p>\n<pre>\u279c jpuyy-shells git:(master) git push --set-upstream origin master\r\nCounting objects: 3, done.\r\nDelta compression using up to 4 threads.\r\nCompressing objects: 100% (2\/2), done.\r\nWriting objects: 100% (3\/3), 408 bytes | 0 bytes\/s, done.\r\nTotal 3 (delta 0), reused 0 (delta 0)\r\nTo git@bitbucket.org:jpuyy\/jpuyy-shells.git\r\n* [new branch] master -&gt; master\r\nBranch master set up to track remote branch master from origin.\r\n<\/pre>\n<p>\u5728develop\u5206\u652f\u4e0b\u83b7\u53d6master\u6700\u65b0<\/p>\n<pre class=\"p1\">git pull origin master<\/pre>\n<p>\u5c06Develop\u5206\u652f\u53d1\u5e03\u5230Master\u5206\u652f\u7684\u547d\u4ee4<\/p>\n<pre># \u5207\u6362\u5230Master\u5206\u652f\r\ngit checkout master\r\n# \u5bf9Develop\u5206\u652f\u8fdb\u884c\u5408\u5e76\r\ngit merge --no-ff develop\r\ngit merge --ff-only develop\r\n<\/pre>\n<p>git clone github \u5e93<\/p>\n<pre>git clone https:\/\/username@github.com\/username\/repo_name . <\/pre>\n<p>git\u76f8\u5173\u7684\u4e00\u4e9b\u547d\u4ee4<\/p>\n<p>git-add . \u53ea\u662f\u5237\u65b0\u4e86git\u7684\u8ddf\u8e2a\u4fe1\u606f\uff0c\u5176\u5b9e\u5e76\u6ca1\u6709\u63d0\u4ea4\u5230 git \u7684\u5185\u5bb9\u8ddf\u8e2a\u8303\u7574\u4e4b\u5185<br \/>\ngit-status \u6211\u4eec\u80fd\u770b\u5230 git \u7684\u72b6\u6001\u63d0\u793a<br \/>\ngit-init-db \u521d\u59cb\u5316git\u6570\u636e\u5e93<br \/>\ngit-add hello.c \u6dfb\u52a0\u6587\u4ef6<br \/>\ngit-log \u67e5\u770b\u4fee\u6539\u3001\u63d0\u4ea4\u8bb0\u5f55<br \/>\ngit-branch bb \u521b\u5efa\u5206\u652f<br \/>\ngit-branch \u67e5\u770b\u5206\u652f<br \/>\ngit-checkout bb \u5207\u6362\u5de5\u4f5c\u5206\u652f<br \/>\n\u8bbe\u7f6e\u63d0\u4ea4\u7684\u7528\u6237\u540d\u548c\u90ae\u7bb1<\/p>\n<pre>git config --global user.name \"jpuyy\"\r\ngit config --global user.email \"jpuyy.com@gmail.com\"\r\n<\/pre>\n<p>\u67e5\u770bgit log\u7684\u65f6\u5019\uff0c\u663e\u793a\u9ad8\u4eae<\/p>\n<pre>git config --local color.ui true<\/pre>\n<p>\u83b7\u53d6\u5f53\u524dconfig\u7684\u4fe1\u606f<\/p>\n<pre class=\"p1\">git config --list<\/pre>\n<p>git\u4f7f\u7528http\u4ee3\u7406<\/p>\n<pre class=\"p1\">git config --global http.<span class=\"s1\"><b>proxy<\/b><\/span> 'socks5:\/\/127.0.0.1:1080'<\/pre>\n<p>git config \u7684\u914d\u7f6e\u53ef\u4ee5\u8c03\u7528\u9ed8\u8ba4\u7f16\u8f91\u5668 vim \u7f16\u8f91<\/p>\n<pre class=\"p1\">git config --global -e<\/pre>\n<p>git-mv roredu.c helight.c \u4fee\u6539\u6587\u4ef6\u540d<\/p>\n<p>\u5355\u72ec\u6062\u590d\u4e00\u4e2a\u6587\u4ef6\u4e3a\u7248\u672c\u5e93\u6700\u65b0\u72b6\u6001<\/p>\n<pre class=\"p1\">git checkout -- config\/index.js<\/pre>\n<p>\u4f7f\u7528git rm \u5220\u9664\u6587\u4ef6<br \/>\ngit rm file1.txt<br \/>\ngit commit -m &#8220;remove file1.txt&#8221;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>ubuntu\u4e0b\u5b89\u88c5git sudo apt-get install git git-core \u6216\u8005\u5230\u65b0\u7acb\u5f97\u8f6f\u4ef6\u5305\u91cc\u9762 \u8f93\u5165 git \u5b89\u88c5\u3002 \u5728\u672c\u5730\u4f7f\u7528git git init git add . git commit -m &#8216;project init&#8217; \u5728\u5e93\u7684\u76ee\u5f55\u4e0b git add . \u00a0 \u00a0 \uff03\u5b58\u50a8\u5230\u672c\u5730 git commit -m &#8216;message&#8217; \u00a0 \u00a0#\u5b58\u50a8\u65f6\u7684\u6807\u8bb0\uff08message\u662f\u8bf4\u660e\u6587\u5b57\uff09 git pull \u00a0 #\u4e0b\u8f7d\u670d\u52a1\u5668\u4ee3\u7801 git push \u00a0 #\u4e0a\u4f20\u4ee3\u7801\u81f3github \u53ea\u68c0\u51fa\u6700\u8fd1\u4e00\u6b21\u63d0\u4ea4\u7684commit git clone git@bitbucket.org:jpuyy\/forge.jpuyy.com.git &#8211;depth=1 \u5df2\u7ecf\u5199\u4e86\u4e00\u4e9b\u4ee3\u7801\u4e4b\u540e\u60f3\u8981\u628a\u4ee3\u7801\u653e\u5165\u5230git\u5e93\u91cc\uff0c\u5148\u653e\u5230\u672c\u5730\uff0c\u518d\u63a8\u5230bitbucket\u4ee3\u7801\u4ed3\u5e93\u91cc cd \/path\/to\/my\/repo git init git add . [&hellip;]<\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8],"tags":[23],"class_list":["post-3223","post","type-post","status-publish","format-standard","hentry","category-linux","tag-summary"],"_links":{"self":[{"href":"https:\/\/jpuyy.com\/index.php?rest_route=\/wp\/v2\/posts\/3223","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/jpuyy.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/jpuyy.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/jpuyy.com\/index.php?rest_route=\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/jpuyy.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=3223"}],"version-history":[{"count":31,"href":"https:\/\/jpuyy.com\/index.php?rest_route=\/wp\/v2\/posts\/3223\/revisions"}],"predecessor-version":[{"id":7221,"href":"https:\/\/jpuyy.com\/index.php?rest_route=\/wp\/v2\/posts\/3223\/revisions\/7221"}],"wp:attachment":[{"href":"https:\/\/jpuyy.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=3223"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/jpuyy.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=3223"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/jpuyy.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=3223"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}