bash 是否可以在没有 git clone 的情况下获取远程 git repo 的提交日志/消息
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/20055398/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Is it possible to get commit logs/messages of a remote git repo without git clone
提问by Murtaza Pitalwala
Is it possible to get commit logs/messages of a remote git repo without git clone?
是否可以在没有 git clone 的情况下获取远程 git repo 的提交日志/消息?
The git repo I am working with is huge, even if I run git clone with --depth=1 still takes sometime before I am able to clone it.
我正在使用的 git repo 很大,即使我使用 --depth=1 运行 git clone 仍然需要一些时间才能克隆它。
I am looking for something like this,
我正在寻找这样的东西,
git remote-log .
git 远程日志。
I have also looked in to git -ls-remote, which only provides the SHA and the Heads/tags. I am interested in getting the last 2 commit title, commit user and commit SHA?
我还查看了 git -ls-remote,它只提供 SHA 和 Heads/标签。我有兴趣获得最后 2 个提交标题、提交用户和提交 SHA?
Anyone know how to do that?
有谁知道怎么做?
采纳答案by Noob
If you are looking to see the last few commits of a branch, try:
如果您想查看分支的最后几次提交,请尝试:
git clone -b [branch name] --single-branch [repo url] --depth=3
This will clone only the last 3 commits on the branch you are interested. Once done you can get into the cloned repo and view the history.
这将仅克隆您感兴趣的分支上的最后 3 个提交。完成后,您可以进入克隆的存储库并查看历史记录。
回答by aust
There is no way to view a remote log using git log
without having a local (cloned) copy. You will need to clone the repository then do what you are wanting. Once cloned, you can then fetch different remotes and do a git log <remote>/<branch>
. An alternative method would be to use software on the server that would allow you to view remote git history through some type of service (such as Stash, GitHub Enterprise, etc.)
如果没有git log
本地(克隆)副本,则无法查看远程日志。您将需要克隆存储库,然后执行您想要的操作。克隆后,您可以获取不同的遥控器并执行git log <remote>/<branch>
. 另一种方法是使用服务器上的软件,该软件允许您通过某种类型的服务(例如 Stash、GitHub Enterprise 等)查看远程 git 历史记录。
See Commit history on remote repository
If you'd like to read more about it, this is a great resource: http://git-scm.com/book/en/Git-Basics-Viewing-the-Commit-History
如果你想阅读更多关于它的信息,这是一个很好的资源:http: //git-scm.com/book/en/Git-Basics-Viewing-the-Commit-History
回答by Anurag Kanungo
Not the exact, but a way around.
不是确切的,而是一种方法。
Use GitHub Developer API
使用 GitHub 开发者 API
1. Opening this will get you the recent commits.
https://api.github.com/repos/learningequality/ka-lite/commits
You can get the specific commit details by attaching the commit hash in the end of above url.
2. All the files ( You need sha for the main tree)
https://api.github.com/repos/learningequality/ka-lite/git/trees/7b698a988683b161bdcd48a949b01e2b336b4c01
I hope this may help.
我希望这可能会有所帮助。
回答by JR ibkr
I came across this problem. In my case, I had access .git file. I was able to extract information from it using following:
我遇到了这个问题。就我而言,我可以访问 .git 文件。我能够使用以下方法从中提取信息:
git --git-dir=path/to/your/xyz.git log