用git查找文件的提交sha [英] Find the commit sha of a file with git

查看:114
本文介绍了用git查找文件的提交sha的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个文件夹,其中包含使用git版本控制的项目的未知版本.文件夹中的项目(未版本化)具有一些小的更改,我将在主要版本化项目中引入.

I have a folder with an unknown version of a project versioned with git. The project in the folder (not versioned) have some minor changes that i would introduce in the main versioned project.

我知道文件夹项目是从提交到我的版本化项目中的时间点开始的.

I know that the folder project started from a commit a point in the time that is in my versioned project.

我想找到原始的开始提交,创建一个分支,应用较小的更改,然后将所有内容提交给主服务器.

I want to find the original starting commit, create a branch, apply the minor changes and then push up everything up to the master.

我该怎么做?我可以假设某些文件没有更改,是否可以找到文件的版本(commit sha)?

How can i do this? I can assume that some files has not changed so, is possible to find a version (commit sha) of a file?

推荐答案

git log --name-only将列出与每个提交sha关联的文件.

git log --name-only will list the files associated with each commit sha.

如果您有特定的文件,可以使用git log \-文件名

If you have a particular file in mind you can use git log \-- filename

例如git log \-main.c

e.g. git log \-- main.c

这将仅显示影响main.c的提交

This will show only commits which affect main.c

这篇关于用git查找文件的提交sha的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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