git am / format-patch / cherry-pick

本文深入探讨了Git在软件开发中如何利用Patch进行版本更新,并详细解释了使用git-am进行合并补丁的方法,包括如何解决冲突以及生成补丁的步骤。同时,对比了git-diff与git-format-patch生成的Patch的优缺点,提供了实用的操作指南。

介绍:

    UNIX世界的软件开发大多都是协作式的,因此,Patch(补丁)是一个相当重要的东西,因为几乎所有的大型UNIX项目的普通贡献者,都是通过 Patch来提交代码的。作为最重要的开源项目之一,Linux,也是这样的。普通开发者从软件仓库clone下代码,然后写入代码,做一个Patch, 最后用E-mail发给Linux Kernel的维护者就好了。Git最初作为Linux的版本控制工具,提供了透明、完整、稳定的Patch功能。

    我们先介绍一下Patch是什么。如果一个软件有了新版本,我们可以完整地下载新版本的代码进行编译安装。然而,像Linux Kernel这样的大型项目,代码即使压缩,也超过70MB,每次全新下载是有相当大的代价的。然而,每次更新变动的代码可能不超过1MB,因此,我们只要能够有两个版本代码的diff的数据,应该就可以以极低的代价更新程序了。因此,Larry Wall开发了一个工具:patch。它可以根据一个diff文件进行版本更新。

    不过在git中,我们没有必要直接使用diff和patch来做补丁,这样做既危险又麻烦。git提供了两种简单的patch方案。一是用git diff生成的标准patch,二是git format-patch生成的Git专用Patch。

diff 和format-patch的比较:

  • 兼容性:很明显,git diff生成的Patch兼容性强。如果你在修改的代码的官方版本库不是Git管理的版本库,那么你必须使用git diff生成的patch才能让你的代码被项目的维护人接受。
  • 除错功能:对于git diff生成的patch,你可以用git apply --check 查看补丁是否能够干净顺利地应用到当前分支中;如果git format-patch 生成的补丁不能打到当前分支,git am会给出提示,并协助你完成打补丁工作,你也可以使用git am -3进行三方合并,详细的做法可以参考git手册或者《Progit》。从这一点上看,两者除错功能都很强。
  • 版本库信息:由于git format-patch生成的补丁中含有这个补丁开发者的名字,因此在应用补丁时,这个名字会被记录进版本库,显然,这样做是恰当的。因此,目前使用Git的开源社区往往建议大家使用format-patch生成补丁。

在使用git-am之前, 你要首先git am –abort 一次,来放弃掉以前的am信息,这样才可以进行一次全新的am,不然会遇到这样的错误。
.git/rebase-apply still exists but mbox given.

git-am 可以一次合并一个文件,或者一个目录下所有的patch,或者你的邮箱目录下的patch.

下面举两个例子:

  1. 你现在有一个code base: small-src, 你的patch文件放在~/patch/0001-trival-patch.patch
cd small-src
git-am ~/patch/0001-trival-patch.patch

如果成功patch上去, 你就可以去喝杯茶了。

如果失败了, git 会提示错误, 比如:

error: patch failed: android/mediascanner.cpp:452
error: android/mediascanner.cpp: patch does not apply

这样你就需要先看看patch, 然后改改错误的这个文件,让这个patch能够patch上去。

  1. 你有一堆patch, 名字是上面提到的那一堆patch, 你把他们放在~/patch-set/目录下(路径随意)
cd opencore
git am ~/patch-set/*.patch

(这里git就会按照文件名的顺序一次am这些patch)
如果一切顺利, 你所有的patch都OK了, 你又Lucky了。

不过不顺利的时候十有八九,如果git am中间遇到了patch,am就会停到打这个
patch的地方, 告诉你是哪个patch打不上去。

比如我现在有一个文件file,有两个patch.
file 的内容是

the text

more text

两个patch分别是:

0001-add-line.patch:

From 48869ccbced494e05738090afa5a54f2a261df0f Mon Sep 17 00:00:00 2001
From: zhangjiejing <zhangjiejing@zhangjiejing-desktop.(none)>
Date: Thu, 22 Apr 2010 13:04:34 +0800
Subject: [PATCH 1/2] add line

---
 file |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/file b/file
index 067780e..685f0fa 100644
--- a/file
+++ b/file
@@ -3,3 +3,5 @@ file:
 some text

 more text
+
+add line
--
1.6.3.3

0002-change-line.patch:

From f756e1b3a87c216b7e0afea9d15badd033171578 Mon Sep 17 00:00:00 2001
From: zhangjiejing <zhangjiejing@zhangjiejing-desktop.(none)>
Date: Thu, 22 Apr 2010 13:05:19 +0800
Subject: [PATCH 2/2] change line

---
 file |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/file b/file
index 685f0fa..7af7852 100644
--- a/file
+++ b/file
@@ -1,6 +1,6 @@
 file:

-some text
+Change line text

 more text

--
1.6.3.3

运行
git am *.patch

来merge这些patch, 报错, Patch failed at 0001 add line这样我们看0001这
个patch,原来patch需要的是some text, 而file里面是the text, 所以我们用编
辑器把这行改成some text,

vi file
git apply 0001-add-line.patch
git add file
git am --resolved

在解决完冲突以后, 比如用git add来让git知道你已经解决完冲突了。

  • 如果你发现这个冲突是无法解决的, 要撤销整个am的东西。 可以运行git am –abort,
  • 如果你想只是忽略这一个patch,可以运行git am –skip来跳过这个patch.

使用git format-patch生成所需要的patch:

# git format-patch -s 1bbe3c8c197a35f79bfddaba099270a2e54ea9c7

please replace the hash code with your repo previous commit.

then you can find the patch under repo directory.

then mail your patch to configuration admin. 


# git format-patch -M master         // 当前分支所有超前master的提交

# git format-patch -s 4e16                // 某次提交以后的所有patch,  --4e16指的是SHA1 ID, -s : signed off

# git format-patch -1                     //  单次提交
# git format-patch -3                    // 从master往前3个提交的内容,可修改为你想要的数值
# git format-patch –n 07fe            // - n指patch数,07fe对应提交的名称, 某次提交(含)之前的几次提交
# git format-patch -1 commit-id// + commit-id 选定的那个commit打patch

git format-patch -s --root origin     // 从origin到指定提交的所有patch

应用patch:
先检查patch文件:# git apply --stat newpatch.patch
检查能否应用成功:# git apply --check  newpatch.patch
打补丁:# git am --signoff < newpatch.patch

(使用-s或--signoff选项,可以commit信息中加入Signed-off-by信息)


今天发现有个需求,就是我提交了错误的提交,如何再切换到先前的版本,但是并没有建立branch的时候,

原来用git checkout 就可以了,

# git checkout 7a1eba1f6d   // SHA1 ID 这种情况只是切换,但是不做任何处理,如果需要反转就用

# git revert

如果需要复位就用

# git reset SHA1 ID

git revert还原最近一次的修改,但版本commit会向前推进,只是创建一个相反的内容,再次提交
git revert commit-id还原指定版本的修改
git reset --hard commit-id   # 整個 Repository 恢復到某個版本的狀態
git reset HEAD^
git reset HEAD~1        撤销最后一次提交,默认模式-mixed,回退commit与index,
git reset --soft 回退commit,但不回退index
git reset --hard HEAD^  撤销最后一次提交并清除本地修改。
git reset commit-id          回到commit-id对应的提交状态。

git rebase -i HEAD~*     // 用来修改commit的内容,可以删除或者修改名字或者移动位置或者合并,然后ctrl+o,ctrl+x保存退出。

  # Commands:
  #  p, pick = use commit
  #  r, reword = use commit, but edit the commit message
  #  e, edit = use commit, but stop for amending
  #  s, squash = use commit, but meld into previous commit
  #  f, fixup = like "squash", but discard this commit's log message

git log -p test.c          // 查看这个文件提交的记录,及内容的修改

git log test.c              // 仅查看提交的记录

git log --oneline -2    // 显示一行,显示最近的两次提交

gitlog --pretty=short

# git config --global alias.lg "log --graph"

# git config -l
alias.lg=log --graph --pretty=format:'%Cred%h%Creset: %s %Cgreen(%cr)%Creset %C(yellow)%d%Creset' --abbrev-commit --date=short
Explain:

%Cred : 显示红色

%h : 简短的commit id

%Creset : 颜色复位成常规的颜色

%s : 显示提交的内容标题

%cr : 显示提交的日期,这个按照比今天前多少天

%Cyellow : 显示黄色

%d : ref name


git add . 

git commit --amend  // 追加到前一次提交,这个类似于 git rebase -i HEAD~2

git show        // 显示最近的一次提交的内容

git show --name-only   // 只显示修改的文件名,而不具体显示修改的行的内容

git grep -n -w  “searched name”   // git 提供的比较方便的搜索方式, -w 只搜索全匹配的字符串,适合于搜索函数名

git am -3 *.patch

git am --ignore-space-change -3 xxx.patch "忽略空格的改变,这个可以忽略windows和linux换行符的差异"

git reset commit-id // 复位到指定的commit,但是会把修改的内容保留在目录下,后面可以修改并继续提交

git blame -L 40,60 test.c      // 责备40行 - 60行
git blame -L 40,+21 test.c    // 责备第40行,及后面21行

git blame --since=3.weeks -- test.c

git am 用了git apply,用它打补丁会生成commit信息。如果出现以下错误:
previous rebase directory ../.git/rebase-apply still exists but mbox given
可以用# git am --abort

丢弃某个commit:

# git revert commit-id -n, --no-commit

实际问题: 
  在本地 master 分支上做了一个commit ( 38361a68138140827b31b72f8bbfd88b3705d77a ) , 如何把它放到 本地 old_cc 分支上? 
办法之一: 使用 cherry-pick.  根据git 文档:

Apply the changes introduced by some existing commits 

就是对已经存在的commit 进行apply (可以理解为再次提交)
简单用法:

git cherry-pick <commit id>

例如:
$ git checkout old_cc
$ git cherry-pick 38361a68     # 这个 38361a68 号码,位于:

$ git log 
commit  38361a68138140827b31b72f8bbfd88b3705d77a 
Author: Siwei Shen <siwei.shen@focusbeijing.com>
Date:   Sat Dec 10 00:09:44 2011 +0800


1. 如果顺利,就会正常提交。结果:

Finished one cherry-pick.
# On branch old_cc
# Your branch is ahead of 'origin/old_cc' by 3 commits.


2. 如果在cherry-pick 的过程中出现了冲突

Automatic cherry-pick failed.  After resolving the conflicts,
mark the corrected paths with 'git add <paths>' or 'git rm <paths>'
and commit the result with: 

        git commit -c 15a2b6c61927e5aed6718de89ad9dafba939a90b


就跟普通的冲突一样,手工解决:
2.1 $ git status    # 看哪些文件出现冲突

both modified:      app/models/user.rb 


2.2 $ vim app/models/user.rb  # 手动解决它。 
2.3 $ git add app/models/user.rb
2.4 git commit -c <新的commit号码>


SUBDIR git-gui SUBDIR gitk-git SUBDIR templates install -d -m 755 '/usr/local/bin' install -d -m 755 '/usr/local/libexec/git-core' install git-daemon git-http-backend git-imap-send git-sh-i18n--envsubst git-shell git-http-fetch git-http-push git-remote-http git-remote-https git-remote-ftp git-remote-ftps git-bisect git-difftool--helper git-filter-branch git-merge-octopus git-merge-one-file git-merge-resolve git-mergetool git-quiltimport git-request-pull git-submodule git-web--browse git-add--interactive git-archimport git-cvsexportcommit git-cvsimport git-cvsserver git-send-email git-svn git-p4 git-instaweb '/usr/local/libexec/git-core' install -m 644 git-mergetool--lib git-rebase--preserve-merges git-sh-i18n git-sh-setup '/usr/local/libexec/git-core' install git git-receive-pack git-shell git-upload-archive git-upload-pack git-cvsserver '/usr/local/bin' make -C templates DESTDIR='' install make[1]: Entering directory `/usr/local/src/git-2.30.0/templates' install -d -m 755 '/usr/local/share/git-core/templates' (cd blt &amp;&amp; tar cf - .) | \ (cd '/usr/local/share/git-core/templates' &amp;&amp; umask 022 &amp;&amp; tar xof -) make[1]: Leaving directory `/usr/local/src/git-2.30.0/templates' install -d -m 755 '/usr/local/libexec/git-core/mergetools' install -m 644 mergetools/* '/usr/local/libexec/git-core/mergetools' install -d -m 755 '/usr/local/share/locale' (cd po/build/locale &amp;&amp; tar cf - .) | \ (cd '/usr/local/share/locale' &amp;&amp; umask 022 &amp;&amp; tar xof -) install -d -m 755 '/usr/local/share/perl5' (cd perl/build/lib &amp;&amp; tar cf - .) | \ (cd '/usr/local/share/perl5' &amp;&amp; umask 022 &amp;&amp; tar xof -) make -C gitweb install make[1]: Entering directory `/usr/local/src/git-2.30.0/gitweb' make[2]: Entering directory `/usr/local/src/git-2.30.0' make[2]: `GIT-VERSION-FILE' is up to date. make[2]: Leaving directory `/usr/local/src/git-2.30.0' install -d -m 755 '/usr/local/share/gitweb' install -m 755 gitweb.cgi '/usr/local/share/gitweb' install -d -m 755 '/usr/local/share/gitweb/static' install -m 644 static/gitweb.js static/gitweb.css static/git-logo.png static/git-favicon.png '/usr/local/share/gitweb/static' make[1]: Leaving directory `/usr/local/src/git-2.30.0/gitweb' make -C gitk-git install make[1]: Entering directory `/usr/local/src/git-2.30.0/gitk-git' install -d -m 755 '/usr/local/bin' install -m 755 gitk-wish '/usr/local/bin'/gitk install -d -m 755 '/usr/local/share/gitk/lib/msgs' install -m 644 po/pt_br.msg '/usr/local/share/gitk/lib/msgs' &amp;&amp; install -m 644 po/bg.msg '/usr/local/share/gitk/lib/msgs' &amp;&amp; install -m 644 po/zh_cn.msg '/usr/local/share/gitk/lib/msgs' &amp;&amp; install -m 644 po/ja.msg '/usr/local/share/gitk/lib/msgs' &amp;&amp; install -m 644 po/ca.msg '/usr/local/share/gitk/lib/msgs' &amp;&amp; install -m 644 po/sv.msg '/usr/local/share/gitk/lib/msgs' &amp;&amp; install -m 644 po/it.msg '/usr/local/share/gitk/lib/msgs' &amp;&amp; install -m 644 po/de.msg '/usr/local/share/gitk/lib/msgs' &amp;&amp; install -m 644 po/pt_pt.msg '/usr/local/share/gitk/lib/msgs' &amp;&amp; install -m 644 po/fr.msg '/usr/local/share/gitk/lib/msgs' &amp;&amp; install -m 644 po/ru.msg '/usr/local/share/gitk/lib/msgs' &amp;&amp; install -m 644 po/vi.msg '/usr/local/share/gitk/lib/msgs' &amp;&amp; install -m 644 po/hu.msg '/usr/local/share/gitk/lib/msgs' &amp;&amp; install -m 644 po/es.msg '/usr/local/share/gitk/lib/msgs' &amp;&amp; true make[1]: Leaving directory `/usr/local/src/git-2.30.0/gitk-git' make -C git-gui gitexecdir='/usr/local/libexec/git-core' install make[1]: Entering directory `/usr/local/src/git-2.30.0/git-gui' DEST /usr/local/libexec/git-core INSTALL 755 git-gui INSTALL 755 git-gui--askpass LINK git-citool -> git-gui DEST /usr/local/share/git-gui/lib INSTALL 644 tclIndex INSTALL 644 themed.tcl INSTALL 644 spellcheck.tcl INSTALL 644 branch_create.tcl INSTALL 644 line.tcl INSTALL 644 console.tcl INSTALL 644 checkout_op.tcl INSTALL 644 remote_add.tcl INSTALL 644 browser.tcl INSTALL 644 option.tcl INSTALL 644 merge.tcl INSTALL 644 index.tcl INSTALL 644 branch_checkout.tcl INSTALL 644 branch.tcl INSTALL 644 chord.tcl INSTALL 644 diff.tcl INSTALL 644 remote.tcl INSTALL 644 sshkey.tcl INSTALL 644 logo.tcl INSTALL 644 choose_font.tcl INSTALL 644 transport.tcl INSTALL 644 encoding.tcl INSTALL 644 mergetool.tcl INSTALL 644 tools.tcl INSTALL 644 tools_dlg.tcl INSTALL 644 status_bar.tcl INSTALL 644 search.tcl INSTALL 644 shortcut.tcl INSTALL 644 branch_rename.tcl INSTALL 644 class.tcl INSTALL 644 remote_branch_delete.tcl INSTALL 644 choose_repository.tcl INSTALL 644 about.tcl INSTALL 644 blame.tcl INSTALL 644 win32.tcl INSTALL 644 choose_rev.tcl INSTALL 644 commit.tcl INSTALL 644 branch_delete.tcl INSTALL 644 date.tcl INSTALL 644 database.tcl INSTALL 644 error.tcl INSTALL 644 git-gui.ico INSTALL 644 win32_shortcut.js DEST /usr/local/share/git-gui/lib/msgs INSTALL 644 nb.msg INSTALL 644 pt_br.msg INSTALL 644 bg.msg INSTALL 644 zh_cn.msg INSTALL 644 ja.msg INSTALL 644 it.msg INSTALL 644 de.msg INSTALL 644 pt_pt.msg INSTALL 644 fr.msg INSTALL 644 ru.msg INSTALL 644 el.msg INSTALL 644 hu.msg INSTALL 644 vi.msg INSTALL 644 sv.msg make[1]: Leaving directory `/usr/local/src/git-2.30.0/git-gui' bindir=$(cd '/usr/local/bin' &amp;&amp; pwd) &amp;&amp; \ execdir=$(cd '/usr/local/libexec/git-core' &amp;&amp; pwd) &amp;&amp; \ destdir_from_execdir_SQ=$(echo 'libexec/git-core' | sed -e 's|[^/][^/]*|..|g') &amp;&amp; \ { test "$bindir/" = "$execdir/" || \ for p in git git-shell git-cvsserver; do \ rm -f "$execdir/$p" &amp;&amp; \ test -n "" &amp;&amp; \ ln -s "$destdir_from_execdir_SQ/bin/$p" "$execdir/$p" || \ { test -z "" &amp;&amp; \ ln "$bindir/$p" "$execdir/$p" 2>/dev/null || \ cp "$bindir/$p" "$execdir/$p" || exit; } \ done; \ } &amp;&amp; \ for p in git-receive-pack git-upload-archive git-upload-pack; do \ rm -f "$bindir/$p" &amp;&amp; \ test -n "" &amp;&amp; \ ln -s "git" "$bindir/$p" || \ { test -z "" &amp;&amp; \ ln "$bindir/git" "$bindir/$p" 2>/dev/null || \ ln -s "git" "$bindir/$p" 2>/dev/null || \ cp "$bindir/git" "$bindir/$p" || exit; }; \ done &amp;&amp; \ for p in git-add git-am git-annotate git-apply git-archive git-bisect--helper git-blame git-branch git-bugreport git-bundle git-cat-file git-check-attr git-check-ignore git-check-mailmap git-check-ref-format git-checkout-index git-checkout git-clean git-clone git-column git-commit-graph git-commit-tree git-commit git-config git-count-objects git-credential-cache--daemon git-credential-cache git-credential-store git-credential git-describe git-diff-files git-diff-index git-diff-tree git-diff git-difftool git-env--helper git-fast-export git-fast-import git-fetch-pack git-fetch git-fmt-merge-msg git-for-each-ref git-for-each-repo git-fsck git-gc git-get-tar-commit-id git-grep git-hash-object git-help git-index-pack git-init-db git-interpret-trailers git-log git-ls-files git-ls-remote git-ls-tree git-mailinfo git-mailsplit git-merge-base git-merge-file git-merge-index git-merge-ours git-merge-recursive git-merge-tree git-merge git-mktag git-mktree git-multi-pack-index git-mv git-name-rev git-notes git-pack-objects git-pack-redundant git-pack-refs git-patch-id git-prune-packed git-prune git-pull git-push git-range-diff git-read-tree git-rebase git-receive-pack git-reflog git-remote-ext git-remote-fd git-remote git-repack git-replace git-rerere git-reset git-rev-list git-rev-parse git-revert git-rm git-send-pack git-shortlog git-show-branch git-show-index git-show-ref git-sparse-checkout git-stash git-stripspace git-submodule--helper git-symbolic-ref git-tag git-unpack-file git-unpack-objects git-update-index git-update-ref git-update-server-info git-upload-archive git-upload-pack git-var git-verify-commit git-verify-pack git-verify-tag git-worktree git-write-tree git-cherry git-cherry-pick git-format-patch git-fsck-objects git-init git-maintenance git-merge-subtree git-restore git-show git-stage git-status git-switch git-whatchanged; do \ rm -f "$execdir/$p" &amp;&amp; \ if test -z ""; \ then \ test -n "" &amp;&amp; \ ln -s "$destdir_from_execdir_SQ/bin/git" "$execdir/$p" || \ { test -z "" &amp;&amp; \ ln "$execdir/git" "$execdir/$p" 2>/dev/null || \ ln -s "git" "$execdir/$p" 2>/dev/null || \ cp "$execdir/git" "$execdir/$p" || exit; }; \ fi \ done &amp;&amp; \ remote_curl_aliases="git-remote-https git-remote-ftp git-remote-ftps" &amp;&amp; \ for p in $remote_curl_aliases; do \ rm -f "$execdir/$p" &amp;&amp; \ test -n "" &amp;&amp; \ ln -s "git-remote-http" "$execdir/$p" || \ { test -z "" &amp;&amp; \ ln "$execdir/git-remote-http" "$execdir/$p" 2>/dev/null || \ ln -s "git-remote-http" "$execdir/$p" 2>/dev/null || \ cp "$execdir/git-remote-http" "$execdir/$p" || exit; } \ done &amp;&amp; \ ./check_bindir "z$bindir" "z$execdir" "$bindir/git-add"
07-15
fuyu1@ubuntu:~/git-2.7.4$ sudo apt install build-essential libssl-dev libcurl4-gnutls-dev libexpat1-dev gettext 正在读取软件包列表... 完成 正在分析软件包的依赖关系树 正在读取状态信息... 完成 gettext 已经是最新的版本。 libssl-dev 已经是最新的版本。 下列软件包是自动安装的并且现在不需要了: git-man liberror-perl Use 'apt-get autoremove' to remove them. 将会安装下列额外的软件包: dpkg-dev fakeroot libalgorithm-diff-perl libalgorithm-diff-xs-perl libalgorithm-merge-perl libdpkg-perl libfakeroot libfile-fcntllock-perl 建议安装: debian-keyring libcurl4-doc libcurl3-dbg 下列软件包将被【卸载】: libcurl4-openssl-dev 下列【新】软件包将被安装: build-essential dpkg-dev fakeroot libalgorithm-diff-perl libalgorithm-diff-xs-perl libalgorithm-merge-perl libcurl4-gnutls-dev libdpkg-perl libexpat1-dev libfakeroot libfile-fcntllock-perl 升级了 0 个软件包,新安装了 11 个软件包,要卸载 1 个软件包,有 4 个软件包未被升级。 需要下载 1,434 kB 的归档。 解压缩后会消耗 4,975 kB 的额外空间。 您希望继续执行吗? [Y/n] y 获取:1 http://rdsource.tp-link.com/ubuntu/ trusty-updates/main libdpkg-perl all 1.17.5ubuntu5.8 [179 kB] 获取:2 http://rdsource.tp-link.com/ubuntu/ trusty-updates/main dpkg-dev all 1.17.5ubuntu5.8 [726 kB] 获取:3 http://rdsource.tp-link.com/ubuntu/ trusty/main build-essential amd64 11.6ubuntu6 [4,838 B] 获取:4 http://rdsource.tp-link.com/ubuntu/ trusty/main libfakeroot amd64 1.20-3ubuntu2 [25.4 kB] 获取:5 http://rdsource.tp-link.com/ubuntu/ trusty/main fakeroot amd64 1.20-3ubuntu2 [55.0 kB] 获取:6 http://rdsource.tp-link.com/ubuntu/ trusty/main libalgorithm-diff-perl all 1.19.02-3 [50.0 kB] 获取:7 http://rdsource.tp-link.com/ubuntu/ trusty/main libalgorithm-diff-xs-perl amd64 0.04-2build4 [12.6 kB] 获取:8 http://rdsource.tp-link.com/ubuntu/ trusty/main libalgorithm-merge-perl all 0.08-2 [12.7 kB] 获取:9 http://rdsource.tp-link.com/ubuntu/ trusty-updates/main libcurl4-gnutls-dev amd64 7.35.0-1ubuntu2.20 [237 kB] 获取:10 http://rdsource.tp-link.com/ubuntu/ trusty-updates/main libexpat1-dev amd64 2.1.0-4ubuntu1.4 [115 kB] 获取:11 http://rdsource.tp-link.com/ubuntu/ trusty/main libfile-fcntllock-perl amd64 0.14-2build1 [15.9 kB] 已下载 1,434 kB,耗时 2秒 (507 kB/s) (正在读取数据库 ... 系统当前共安装有 106043 个文件和目录。) 正在卸载 libcurl4-openssl-dev:amd64 (7.35.0-1ubuntu2.20) ... 正在处理用于 man-db (2.6.7.1-1ubuntu1) 的触发器 ... 正在选中未选择的软件包 libdpkg-perl。 (正在读取数据库 ... 系统当前共安装有 106022 个文件和目录。) 正准备解包 .../libdpkg-perl_1.17.5ubuntu5.8_all.deb ... 正在解包 libdpkg-perl (1.17.5ubuntu5.8) ... 正在选中未选择的软件包 dpkg-dev。 正准备解包 .../dpkg-dev_1.17.5ubuntu5.8_all.deb ... 正在解包 dpkg-dev (1.17.5ubuntu5.8) ... 正在选中未选择的软件包 build-essential。 正准备解包 .../build-essential_11.6ubuntu6_amd64.deb ... 正在解包 build-essential (11.6ubuntu6) ... 正在选中未选择的软件包 libfakeroot:amd64。 正准备解包 .../libfakeroot_1.20-3ubuntu2_amd64.deb ... 正在解包 libfakeroot:amd64 (1.20-3ubuntu2) ... 正在选中未选择的软件包 fakeroot。 正准备解包 .../fakeroot_1.20-3ubuntu2_amd64.deb ... 正在解包 fakeroot (1.20-3ubuntu2) ... 正在选中未选择的软件包 libalgorithm-diff-perl。 正准备解包 .../libalgorithm-diff-perl_1.19.02-3_all.deb ... 正在解包 libalgorithm-diff-perl (1.19.02-3) ... 正在选中未选择的软件包 libalgorithm-diff-xs-perl。 正准备解包 .../libalgorithm-diff-xs-perl_0.04-2build4_amd64.deb ... 正在解包 libalgorithm-diff-xs-perl (0.04-2build4) ... 正在选中未选择的软件包 libalgorithm-merge-perl。 正准备解包 .../libalgorithm-merge-perl_0.08-2_all.deb ... 正在解包 libalgorithm-merge-perl (0.08-2) ... 正在选中未选择的软件包 libcurl4-gnutls-dev:amd64。 正准备解包 .../libcurl4-gnutls-dev_7.35.0-1ubuntu2.20_amd64.deb ... 正在解包 libcurl4-gnutls-dev:amd64 (7.35.0-1ubuntu2.20) ... 正在选中未选择的软件包 libexpat1-dev:amd64。 正准备解包 .../libexpat1-dev_2.1.0-4ubuntu1.4_amd64.deb ... 正在解包 libexpat1-dev:amd64 (2.1.0-4ubuntu1.4) ... 正在选中未选择的软件包 libfile-fcntllock-perl。 正准备解包 .../libfile-fcntllock-perl_0.14-2build1_amd64.deb ... 正在解包 libfile-fcntllock-perl (0.14-2build1) ... 正在处理用于 man-db (2.6.7.1-1ubuntu1) 的触发器 ... 正在设置 libdpkg-perl (1.17.5ubuntu5.8) ... 正在设置 dpkg-dev (1.17.5ubuntu5.8) ... 正在设置 build-essential (11.6ubuntu6) ... 正在设置 libfakeroot:amd64 (1.20-3ubuntu2) ... 正在设置 fakeroot (1.20-3ubuntu2) ... update-alternatives: using /usr/bin/fakeroot-sysv to provide /usr/bin/fakeroot (fakeroot) in 自动模式 正在设置 libalgorithm-diff-perl (1.19.02-3) ... 正在设置 libalgorithm-diff-xs-perl (0.04-2build4) ... 正在设置 libalgorithm-merge-perl (0.08-2) ... 正在设置 libcurl4-gnutls-dev:amd64 (7.35.0-1ubuntu2.20) ... 正在设置 libexpat1-dev:amd64 (2.1.0-4ubuntu1.4) ... 正在设置 libfile-fcntllock-perl (0.14-2build1) ... fuyu1@ubuntu:~/git-2.7.4$ make prefix=/usr/local all SUBDIR git-gui SUBDIR gitk-git SUBDIR perl SUBDIR templates fuyu1@ubuntu:~/git-2.7.4$ sudo make prefix=/usr/local install SUBDIR git-gui SUBDIR gitk-git SUBDIR perl SUBDIR templates install -d -m 755 '/usr/local/bin' install -d -m 755 '/usr/local/libexec/git-core' install git-credential-store git-daemon git-fast-import git-http-backend git-imap-send git-sh-i18n--envsubst git-shell git-show-index git-upload-pack git-remote-testsvn git-http-fetch git-credential-cache git-credential-cache--daemon git-remote-http git-remote-https git-remote-ftp git-remote-ftps git-bisect git-difftool--helper git-filter-branch git-merge-octopus git-merge-one-file git-merge-resolve git-mergetool git-quiltimport git-rebase git-request-pull git-stash git-submodule git-web--browse git-add--interactive git-difftool git-archimport git-cvsexportcommit git-cvsimport git-cvsserver git-relink git-send-email git-svn git-p4 git-instaweb '/usr/local/libexec/git-core' install -m 644 git-mergetool--lib git-parse-remote git-rebase--am git-rebase--interactive git-rebase--merge git-sh-setup git-sh-i18n '/usr/local/libexec/git-core' install git git-upload-pack git-receive-pack git-upload-archive git-shell git-cvsserver '/usr/local/bin' make -C templates DESTDIR='' install make[1]: 正在进入目录 `/home/fuyu1/git-2.7.4/templates' install -d -m 755 '/usr/local/share/git-core/templates' (cd blt &amp;&amp; tar cf - .) | \ (cd '/usr/local/share/git-core/templates' &amp;&amp; umask 022 &amp;&amp; tar xof -) make[1]:正在离开目录 `/home/fuyu1/git-2.7.4/templates' install -d -m 755 '/usr/local/libexec/git-core/mergetools' install -m 644 mergetools/* '/usr/local/libexec/git-core/mergetools' install -d -m 755 '/usr/local/share/locale' (cd po/build/locale &amp;&amp; tar cf - .) | \ (cd '/usr/local/share/locale' &amp;&amp; umask 022 &amp;&amp; tar xof -) make -C perl prefix='/usr/local' DESTDIR='' install make[1]: 正在进入目录 `/home/fuyu1/git-2.7.4/perl' make[2]: 正在进入目录 `/home/fuyu1/git-2.7.4/perl' Appending installation info to /usr/local/lib/perl/5.18.2/perllocal.pod make[2]:正在离开目录 `/home/fuyu1/git-2.7.4/perl' make[1]:正在离开目录 `/home/fuyu1/git-2.7.4/perl' make -C gitweb install make[1]: 正在进入目录 `/home/fuyu1/git-2.7.4/gitweb' make[2]: 正在进入目录 `/home/fuyu1/git-2.7.4' make[2]: “GIT-VERSION-FILE”是最新的。 make[2]:正在离开目录 `/home/fuyu1/git-2.7.4' install -d -m 755 '/usr/local/share/gitweb' install -m 755 gitweb.cgi '/usr/local/share/gitweb' install -d -m 755 '/usr/local/share/gitweb/static' install -m 644 static/gitweb.js static/gitweb.css static/git-logo.png static/git-favicon.png '/usr/local/share/gitweb/static' make[1]:正在离开目录 `/home/fuyu1/git-2.7.4/gitweb' make -C gitk-git install make[1]: 正在进入目录 `/home/fuyu1/git-2.7.4/gitk-git' install -m 755 gitk-wish '/usr/local/bin'/gitk install -d -m 755 '/usr/local/share/gitk/lib/msgs' install -m 644 po/bg.msg '/usr/local/share/gitk/lib/msgs' &amp;&amp; install -m 644 po/ca.msg '/usr/local/share/gitk/lib/msgs' &amp;&amp; install -m 644 po/de.msg '/usr/local/share/gitk/lib/msgs' &amp;&amp; install -m 644 po/es.msg '/usr/local/share/gitk/lib/msgs' &amp;&amp; install -m 644 po/fr.msg '/usr/local/share/gitk/lib/msgs' &amp;&amp; install -m 644 po/hu.msg '/usr/local/share/gitk/lib/msgs' &amp;&amp; install -m 644 po/it.msg '/usr/local/share/gitk/lib/msgs' &amp;&amp; install -m 644 po/ja.msg '/usr/local/share/gitk/lib/msgs' &amp;&amp; install -m 644 po/pt_br.msg '/usr/local/share/gitk/lib/msgs' &amp;&amp; install -m 644 po/ru.msg '/usr/local/share/gitk/lib/msgs' &amp;&amp; install -m 644 po/sv.msg '/usr/local/share/gitk/lib/msgs' &amp;&amp; install -m 644 po/vi.msg '/usr/local/share/gitk/lib/msgs' &amp;&amp; true make[1]:正在离开目录 `/home/fuyu1/git-2.7.4/gitk-git' make -C git-gui gitexecdir='/usr/local/libexec/git-core' install make[1]: 正在进入目录 `/home/fuyu1/git-2.7.4/git-gui' DEST /usr/local/libexec/git-core INSTALL 755 git-gui INSTALL 755 git-gui--askpass LINK git-citool -> git-gui DEST /usr/local/share/git-gui/lib INSTALL 644 tclIndex INSTALL 644 about.tcl INSTALL 644 blame.tcl INSTALL 644 branch_checkout.tcl INSTALL 644 branch_create.tcl INSTALL 644 branch_delete.tcl INSTALL 644 branch_rename.tcl INSTALL 644 branch.tcl INSTALL 644 browser.tcl INSTALL 644 checkout_op.tcl INSTALL 644 choose_font.tcl INSTALL 644 choose_repository.tcl INSTALL 644 choose_rev.tcl INSTALL 644 class.tcl INSTALL 644 commit.tcl INSTALL 644 console.tcl INSTALL 644 database.tcl INSTALL 644 date.tcl INSTALL 644 diff.tcl INSTALL 644 encoding.tcl INSTALL 644 error.tcl INSTALL 644 index.tcl INSTALL 644 line.tcl INSTALL 644 logo.tcl INSTALL 644 merge.tcl INSTALL 644 mergetool.tcl INSTALL 644 option.tcl INSTALL 644 remote_add.tcl INSTALL 644 remote_branch_delete.tcl INSTALL 644 remote.tcl INSTALL 644 search.tcl INSTALL 644 shortcut.tcl INSTALL 644 spellcheck.tcl INSTALL 644 sshkey.tcl INSTALL 644 status_bar.tcl INSTALL 644 themed.tcl INSTALL 644 tools_dlg.tcl INSTALL 644 tools.tcl INSTALL 644 transport.tcl INSTALL 644 win32.tcl INSTALL 644 git-gui.ico INSTALL 644 win32_shortcut.js DEST /usr/local/share/git-gui/lib/msgs INSTALL 644 bg.msg INSTALL 644 de.msg INSTALL 644 el.msg INSTALL 644 fr.msg INSTALL 644 hu.msg INSTALL 644 it.msg INSTALL 644 ja.msg INSTALL 644 nb.msg INSTALL 644 pt_br.msg INSTALL 644 ru.msg INSTALL 644 sv.msg INSTALL 644 vi.msg INSTALL 644 zh_cn.msg make[1]:正在离开目录 `/home/fuyu1/git-2.7.4/git-gui' bindir=$(cd '/usr/local/bin' &amp;&amp; pwd) &amp;&amp; \ execdir=$(cd '/usr/local/libexec/git-core' &amp;&amp; pwd) &amp;&amp; \ { test "$bindir/" = "$execdir/" || \ for p in git git-shell git-upload-pack git-cvsserver; do \ rm -f "$execdir/$p" &amp;&amp; \ test -z "" &amp;&amp; \ ln "$bindir/$p" "$execdir/$p" 2>/dev/null || \ cp "$bindir/$p" "$execdir/$p" || exit; \ done; \ } &amp;&amp; \ for p in git-receive-pack git-upload-archive; do \ rm -f "$bindir/$p" &amp;&amp; \ test -z "" &amp;&amp; \ ln "$bindir/git" "$bindir/$p" 2>/dev/null || \ ln -s "git" "$bindir/$p" 2>/dev/null || \ cp "$bindir/git" "$bindir/$p" || exit; \ done &amp;&amp; \ for p in git-add git-am git-annotate git-apply git-archive git-bisect--helper git-blame git-branch git-bundle git-cat-file git-check-attr git-check-ignore git-check-mailmap git-check-ref-format git-checkout-index git-checkout git-clean git-clone git-column git-commit-tree git-commit git-config git-count-objects git-credential git-describe git-diff-files git-diff-index git-diff-tree git-diff git-fast-export git-fetch-pack git-fetch git-fmt-merge-msg git-for-each-ref git-fsck git-gc git-get-tar-commit-id git-grep git-hash-object git-help git-index-pack git-init-db git-interpret-trailers git-log git-ls-files git-ls-remote git-ls-tree git-mailinfo git-mailsplit git-merge git-merge-base git-merge-file git-merge-index git-merge-ours git-merge-recursive git-merge-tree git-mktag git-mktree git-mv git-name-rev git-notes git-pack-objects git-pack-redundant git-pack-refs git-patch-id git-prune-packed git-prune git-pull git-push git-read-tree git-receive-pack git-reflog git-remote git-remote-ext git-remote-fd git-repack git-replace git-rerere git-reset git-rev-list git-rev-parse git-revert git-rm git-send-pack git-shortlog git-show-branch git-show-ref git-stripspace git-submodule--helper git-symbolic-ref git-tag git-unpack-file git-unpack-objects git-update-index git-update-ref git-update-server-info git-upload-archive git-var git-verify-commit git-verify-pack git-verify-tag git-worktree git-write-tree git-cherry git-cherry-pick git-format-patch git-fsck-objects git-init git-merge-subtree git-show git-stage git-status git-whatchanged; do \ rm -f "$execdir/$p" &amp;&amp; \ test -z "" &amp;&amp; \ ln "$execdir/git" "$execdir/$p" 2>/dev/null || \ ln -s "git" "$execdir/$p" 2>/dev/null || \ cp "$execdir/git" "$execdir/$p" || exit; \ done &amp;&amp; \ remote_curl_aliases="git-remote-https git-remote-ftp git-remote-ftps" &amp;&amp; \ for p in $remote_curl_aliases; do \ rm -f "$execdir/$p" &amp;&amp; \ test -z "" &amp;&amp; \ ln "$execdir/git-remote-http" "$execdir/$p" 2>/dev/null || \ ln -s "git-remote-http" "$execdir/$p" 2>/dev/null || \ cp "$execdir/git-remote-http" "$execdir/$p" || exit; \ done &amp;&amp; \ ./check_bindir "z$bindir" "z$execdir" "$bindir/git-add" fuyu1@ubuntu:~/git-2.7.4$ git --version -bash: /usr/bin/git: 没有那个文件或目录
09-03
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值