{"id":1250,"date":"2016-12-20T21:28:05","date_gmt":"2016-12-20T13:28:05","guid":{"rendered":"https:\/\/yanjingang.com\/blog\/?p=1250"},"modified":"2025-12-12T14:15:23","modified_gmt":"2025-12-12T06:15:23","slug":"git%e5%b8%b8%e7%94%a8%e5%91%bd%e4%bb%a4%e4%b8%8esvn%e5%91%bd%e4%bb%a4%e5%af%b9%e6%af%94","status":"publish","type":"post","link":"https:\/\/yanjingang.com\/blog\/?p=1250","title":{"rendered":"Git\u5e38\u7528\u547d\u4ee4"},"content":{"rendered":"<p>\u4e00\u4e9b\u5e38\u7528\u7684Git\u547d\u4ee4\u3002<\/p>\n<h4><strong>1.\u4e0eSvn\u547d\u4ee4\u5bf9\u6bd4<\/strong><\/h4>\n<table class=\"confluenceTable\">\n<tbody>\n<tr>\n<td class=\"confluenceTd\">\u573a\u666f<\/td>\n<td class=\"confluenceTd\">Svn<\/td>\n<td class=\"confluenceTd\">Git<\/td>\n<\/tr>\n<tr>\n<td class=\"confluenceTd\">\u4e0b\u8f7d\u4ee3\u7801<\/td>\n<td class=\"confluenceTd\">svn checkout<\/td>\n<td class=\"confluenceTd\">git clone<\/td>\n<\/tr>\n<tr>\n<td class=\"confluenceTd\">\u52a0\u5165\u7248\u672c\u63a7\u5236<\/td>\n<td class=\"confluenceTd\">svn add<\/td>\n<td class=\"confluenceTd\">git add<\/td>\n<\/tr>\n<tr>\n<td class=\"confluenceTd\">\u672c\u5730\u63d0\u4ea4<\/td>\n<td class=\"confluenceTd\">&#8211;<\/td>\n<td class=\"confluenceTd\">git commit<\/td>\n<\/tr>\n<tr>\n<td class=\"confluenceTd\">\u63d0\u4ea4\u5230\u670d\u52a1\u5668<\/td>\n<td class=\"confluenceTd\">svn commit<\/td>\n<td class=\"confluenceTd\">git push<\/td>\n<\/tr>\n<tr>\n<td class=\"confluenceTd\">\u83b7\u53d6\u5176\u4ed6\u4eba\u7684\u66f4\u65b0<\/td>\n<td class=\"confluenceTd\">svn update<\/td>\n<td class=\"confluenceTd\">git fetch\/pull[fetch\u4e0d\u4f1a\u81ea\u52a8merge\uff0cpull\u81ea\u52a8merge]<\/td>\n<\/tr>\n<tr>\n<td class=\"confluenceTd\">\u67e5\u770b\u72b6\u6001<\/td>\n<td class=\"confluenceTd\">svn status \/ log \/ diff<\/td>\n<td class=\"confluenceTd\">git status \/ log \/ diff<\/td>\n<\/tr>\n<tr>\n<td class=\"confluenceTd\">\u65b0\u5efa\u672c\u5730\u5206\u652f<\/td>\n<td class=\"confluenceTd\">&#8211;<\/td>\n<td class=\"confluenceTd\">git branch<\/td>\n<\/tr>\n<tr>\n<td class=\"confluenceTd\">\u5207\u6362\u5206\u652f\/\u7248\u672c<\/td>\n<td class=\"confluenceTd\">svn switch<\/td>\n<td class=\"confluenceTd\">git checkout<\/td>\n<\/tr>\n<tr>\n<td class=\"confluenceTd\">\u5408\u5e76\u5206\u652f<\/td>\n<td class=\"confluenceTd\">svn merge<\/td>\n<td class=\"confluenceTd\">git merge\/rebase<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h4 class=\"entry-title\"><strong>2.git add\u5ffd\u7565\u7279\u5b9a\u6587\u4ef6\uff1a<\/strong><\/h4>\n<pre class=\"pure-highlightjs\"><code class=\"\">vim .gitignore\r\n*.pyc\r\n*.pyo\r\n*.log\r\n*.out\r\n*.bak\r\n*.tmp\r\n*.gz\r\n*.tar\r\n*~\r\n*.swp\r\n.DS_Store\r\ncore.*\r\noutput\r\nlog\r\noutput\r\n._*\r\n.vscode\r\n.idea<\/code><\/pre>\n<h4><strong>3.\u8bbe\u7f6e\u5355\u6b21\u63d0\u4ea4\u6587\u4ef6\u6700\u5927\u5927\u5c0f\uff1a<\/strong><\/h4>\n<pre class=\"pure-highlightjs\"><code class=\"\">git config --global http.postBuffer 1048576000\u00a0 \u00a0 #1G<\/code><\/pre>\n<h4><strong>4.github\u4e0a\u4f20&gt;100M\u6587\u4ef6\u7684\u65b9\u6cd5\uff1a<\/strong><\/h4>\n<pre class=\"pure-highlightjs\"><code class=\"\">1.\u5b89\u88c5git-lfs    # https:\/\/git-lfs.github.com\/\r\n  brew install git-lfs\u00a0 \u00a0\r\n  or\r\n  curl -s https:\/\/packagecloud.io\/install\/repositories\/github\/git-lfs\/script.deb.sh | sudo bash\r\n  sudo apt install git-lfs\r\n2.\u8bbe\u7f6egit-lfs\r\n  cd ${project_path}\r\n  git lfs install\r\n  git lfs track \"*.tgz\"     or     vim .gitattributes\r\n  git add .gitattributes   #.gitattributes\u4e2d\u914d\u7f6e\u7684*.tgz\u6587\u4ef6\u4f1a\u81ea\u52a8\u4e0a\u4f20\u5230gitlfs\r\n3.\u6309\u5e73\u65f6\u7684git\u64cd\u4f5c\u5373\u53ef\r\n  git add yourLargeFile.tgz\r\n  git commit -m \"Add Large file\"\r\n  # git config lfs.https:\/\/gitxx\/xxx.git\/info\/lfs.locksverify false   # if get Remote \"origin\" does not support the Git LFS locking API\r\n  # rm .git\/hooks\/pre-push   # if get Message: LFS only supported repository in paid or trial enterprise.: exit status 1\r\n  git push\r\n  # Uploading LFS objects: 100% (1\/1), 114 MB | 0 B\/s, done\r\n4.\u4e0d\u62c9\u53d6lfs\u6587\u4ef6\u7684\u65b9\u6cd5\r\n  GIT_LFS_SKIP_SMUDGE<span class=\"token operator\">=<\/span>1 <span class=\"token function\">git<\/span> clone <span class=\"token operator\">&lt;<\/span>repository-addr<span class=\"token operator\">&gt;\r\n  GIT_LFS_SKIP_SMUDGE=1 <span class=\"token function\">git<\/span> pull\r\n  git lfs uninstall\r\n  rm .gitattributes<\/span><\/code><\/pre>\n<p>*\u6ce8\uff1a\u56fd\u5185\u7684Gitee LFS\u529f\u80fd\u53ea\u5bf9\u4ed8\u8d39\u4f01\u4e1a\u5f00\u653e\uff0c\u514d\u8d39\u7528\u6237\u53ea\u80fd\u4e0a\u4f20\u4e0d\u80fd\u4e0b\u8f7d\uff0c\u9700\u8981\u6ce8\u610f\uff08\u4e5f\u53ef\u4ee5\u8003\u8651\u5207\u5272\u6210&lt;100M\u7684\u6587\u4ef6\u7528\u666e\u901a\u65b9\u5f0f\u4e0a\u4f20\uff09\u3002<\/p>\n<h4><strong>5.\u4e22\u5f03\u672c\u5730\u63d0\u4ea4\uff0c\u5f3a\u5236\u56de\u5230\u7ebf\u4e0a\u6700\u65b0\u7248\u672c<\/strong><\/h4>\n<pre class=\"pure-highlightjs\"><code class=\"\">git fetch --all\r\ngit reset --hard origin \u9700\u8981\u4e0b\u62c9\u7684\u5206\u652f(\u9ed8\u8ba4master)\r\ngit fetch<\/code><\/pre>\n<h4><strong>6.\u786e\u4fdd\u4e0dpush\u5e26\u81ea\u52a8merge\u7684\u63d0\u4ea4\uff0c\u4fdd\u6301\u8bc4\u5ba1\u5386\u53f2\u7ebf\u6027<\/strong><\/h4>\n<pre class=\"pure-highlightjs\"><code class=\"\">git log --pretty=oneline --decorate --graph  #\u627e\u5230merge\u8282\u70b9\r\ngit reset 833011\uff08merge\u8282\u70b9\u4e4b\u524d\u7684commitid\uff09\r\ngit add .\r\ngit commit -m \"xxx\"\r\ngit push<\/code><\/pre>\n<h4><strong>7.\u5c06\u5176\u4ed6\u5206\u652f\u7684commit\u5408\u5e76\u5230\u5f53\u524d\u5206\u652f<\/strong><\/h4>\n<pre class=\"pure-highlightjs\"><code class=\"\"># \u5207\u6362\u5230\u76ee\u6807\u5206\u652f\r\ngit checkout RB_1-0-1\r\n# \u5c06\u5176\u4ed6\u5206\u652f\u7684commit\u5185\u5bb9\u540c\u6b65\u5230\u5f53\u524d\u5206\u652f\u4e2d\r\ngit cherry-pick &lt;commitId&gt;\r\n# \u67e5\u770b\u901a\u8fc7\u8fc7\u6765\u7684commit\u5185\u5bb9\r\ngit diff<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u4e00\u4e9b\u5e38\u7528\u7684Git\u547d\u4ee4\u3002 1.\u4e0eSvn\u547d\u4ee4\u5bf9\u6bd4 \u573a\u666f Svn Git \u4e0b\u8f7d\u4ee3\u7801 svn checkout git [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[452],"tags":[472,712,713],"_links":{"self":[{"href":"https:\/\/yanjingang.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/1250"}],"collection":[{"href":"https:\/\/yanjingang.com\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/yanjingang.com\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/yanjingang.com\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/yanjingang.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1250"}],"version-history":[{"count":4,"href":"https:\/\/yanjingang.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/1250\/revisions"}],"predecessor-version":[{"id":10237,"href":"https:\/\/yanjingang.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/1250\/revisions\/10237"}],"wp:attachment":[{"href":"https:\/\/yanjingang.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1250"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/yanjingang.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1250"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/yanjingang.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1250"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}