Git:自从初始化/克隆以来,我已经*提交的提交历史记录 [英] Git: History of commits I have *checked out* since init/cloning

查看:197
本文介绍了Git:自从初始化/克隆以来,我已经*提交的提交历史记录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设我有一个git仓库,永不提交更改,仅用它来阅读其内容。每隔不久我都会从远程原点拉起来,以便及时了解最新的变化。



有没有一种方法可以让我知道自从我检出哪些版本我克隆了存储库?



为什么我需要这个?



我遇到的问题是我从远程很少,并且项目发展很快,所以我想跟踪过去曾使用(即检出)的提交情况,以防万一我想将我的工作目录还原为我知道它在为我工作。请记住,我只对我实际签出的提交感兴趣。



更新:
看起来我可以做这与标签(标签之前我拉),虽然我无法弄清楚如何获得git 只列出我的标签 。不过,我想知道git是否已经已经为我检查了我已经签出的提交。 解决方案

您可以使用reflog,但只能达到其限制(有时会被清除)。例如 - 一个本地克隆msysGit的快速测试:

  $ git log -g --oneline --abbrev-commit --grep-reflogpull:
53e28dd HEAD @ {7}:pull:快进
947ccf6 HEAD @ {9}:pull:快进
6bf64a4 HEAD @ {10 }:pull:快进
20344ae HEAD @ {15}:pull:通过'递归'策略进行合并。
31dd6ff HEAD @ {36}:拉:快进
b4546cc HEAD @ {37}:拉:快进
fd6f8d0 HEAD @ {38}:拉:快进
4fc3780 HEAD @ {41}:pull:快进

这表明提交ID是I在过去的几个月里,这个系统碰巧做了'拉'。 git log -g git reflog 的更详细版本。



如果您只是执行 git log -g ,您可能会在提供的集合中看到更适合的选择。结账可能对您有用。


Say I have a git repository where I never commit changes and only use it to read its contents. Every now and then I pull from origin remote to stay up to date with the most recent changes.

Is there a way for me to know which versions I have checked out since I cloned the repository?

Why do I need this?

The problem I have is that I pull from the remote rarely and the project evolves quickly, so I would like to keep track of the commits that I have used (i.e. checked out) in the past, in case I want to revert my working directory to a state where I know it was working for me. Remember, I am only interested in the commits that I have actually checked out.

Update: It looks like I can do this with tags (tag before I pull), although I can't figure out how to get git to only list my tags. Still, I was wondering if git would already keep track for me of the commits I have checked out.

解决方案

You can use the reflog for this but only up to its limit (it gets cleaned out sometimes). For instance - a quick test on a local clone of msysGit:

$ git log -g --oneline --abbrev-commit --grep-reflog "pull:"
53e28dd HEAD@{7}: pull: Fast-forward
947ccf6 HEAD@{9}: pull: Fast-forward
6bf64a4 HEAD@{10}: pull: Fast-forward
20344ae HEAD@{15}: pull: Merge made by the 'recursive' strategy.
31dd6ff HEAD@{36}: pull: Fast-forward
b4546cc HEAD@{37}: pull: Fast-forward
fd6f8d0 HEAD@{38}: pull: Fast-forward
4fc3780 HEAD@{41}: pull: Fast-forward

This shows the commit id's that I happened to do 'pull' for on this system over the last few months. git log -g is the more detailed version of git reflog.

If you just do a git log -g you might see more appropriate things to select for in the set provided. Checkouts might be useful to you.

这篇关于Git:自从初始化/克隆以来,我已经*提交的提交历史记录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆