log - git tag commit




從分支獲取最新git commit hash的命令 (4)

如何在命令行中檢查特定git分支的最新提交哈希?


你可以git fetch nameofremoterepo ,然後git log

個人而言,我將gitlog別名為git log --graph --oneline --pretty --decorate --all 。 試試看它是否適合你


使用git ls-remote git://github.com/<user>/<project>.git 。 例如,我的trac-backlog項目給出:

:: git ls-remote git://github.com/jszakmeister/trac-backlog.git
5d6a3c973c254378738bdbc85d72f14aefa316a0    HEAD
4652257768acef90b9af560295b02d0ac6e7702c    refs/heads/0.1.x
35af07bc99c7527b84e11a8632bfb396823326f3    refs/heads/0.2.x
5d6a3c973c254378738bdbc85d72f14aefa316a0    refs/heads/master
520dcebff52506682d6822ade0188d4622eb41d1    refs/pull/11/head
6b2c1ed650a7ff693ecd8ab1cb5c124ba32866a2    refs/pull/11/merge
51088b60d66b68a565080eb56dbbc5f8c97c1400    refs/pull/12/head
127c468826c0c77e26a5da4d40ae3a61e00c0726    refs/pull/12/merge
2401b5537224fe4176f2a134ee93005a6263cf24    refs/pull/15/head
8aa9aedc0e3a0d43ddfeaf0b971d0ae3a23d57b3    refs/pull/15/merge
d96aed93c94f97d328fc57588e61a7ec52a05c69    refs/pull/7/head
f7c1e8dabdbeca9f9060de24da4560abc76e77cd    refs/pull/7/merge
aa8a935f084a6e1c66aa939b47b9a5567c4e25f5    refs/pull/8/head
cd258b82cc499d84165ea8d7a23faa46f0f2f125    refs/pull/8/merge
c10a73a8b0c1809fcb3a1f49bdc1a6487927483d    refs/tags/0.1.0
a39dad9a1268f7df256ba78f1166308563544af1    refs/tags/0.2.0
2d559cf785816afd69c3cb768413c4f6ca574708    refs/tags/0.2.1
434170523d5f8aad05dc5cf86c2a326908cf3f57    refs/tags/0.2.2
d2dfe40cb78ddc66e6865dcd2e76d6bc2291d44c    refs/tags/0.3.0
9db35263a15dcdfbc19ed0a1f7a9e29a40507070    refs/tags/0.3.0^{}

只需grep你需要的那個並切掉它:

:: git ls-remote git://github.com/jszakmeister/trac-backlog.git | \
   grep refs/heads/master | cut -f 1
5d6a3c973c254378738bdbc85d72f14aefa316a0

或者,您可以在命令行中指定所需的引用,並避免使用grep:

:: git ls-remote git://github.com/jszakmeister/trac-backlog.git refs/heads/master | \
   cut -f 1
5d6a3c973c254378738bdbc85d72f14aefa316a0

注意:它不必是git:// url,它可以是https://[email protected]:也是。


在執行git checkout branchname後嘗試使用git log -n 1 。 這顯示了最新提交的提交哈希,作者,日期和提交消息。

首先執行git pull origin/branchname ,以確保您的本地git pull origin/branchname與上游匹配。

如果您可能只希望在遠程分支上看到本地分支落後的提交列表,請執行以下操作:

git fetch origin
git cherry localbranch remotebranch

這將列出尚未合併到本地分支的提交的所有哈希值。


請注意,使用“git log -n 1 [branch_name]”選項時。 -n只返回一行日誌,但不保證返回的順序。 以下是從git-log手冊頁中提取的

.....
.....
Commit Limiting

Besides specifying a range of commits that should be listed using the special notations explained in the     description, additional commit limiting may be applied.

Using more options generally further limits the output (e.g. --since=<date1> limits to commits newer than <date1>, and using it with --grep=<pattern> further limits to commits whose log message has a line that matches <pattern>), unless otherwise noted.

Note that these are applied before commit ordering and formatting options, such as --reverse.

-<number>
-n <number>
.....
.....




github