top button
Flag Notify
    Connect to us
      Facebook Login
      Site Registration

Facebook Login
Site Registration

Git: How to fetch a file at specific checksum?

+1 vote

I am new in git and I am trying to understand it.

I have this case:

a. I develop a html file in several days with daily commit.
b. Some weeks after I noticed that I lost part of the code.
c. I located a code 3 commits ago.

then how I can fetch from the remote repository the html file as was 3 commit before (the whole file)?

posted Oct 28, 2015 by anonymous

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

0 votes

No need to fetch the file from remote repository, as git is distributed version control in your local repository also the same file will be there, just you have toi extract based on commit number.

As according to ur case you want the file as same the three commit before, so just use git log and get the commit number which is 3 commits back from current commit. Then use git checkout by giving file name and commit number as input.

git checkout <CommitNumber, in which you think file was proper>

answer Mar 6, 2016 by Sachidananda Sahu
Similar Questions
0 votes

I am trying to convert my SVN repo to GIT using GIT-SVN and after a few commits being process am running in to following error

: git svn fetch...r1878 = 79e09734fdb4916276da8273f25ecfbff37954a6 (refs/remotes/svn/nt/notecards)Checksum mismatch: dashboard-merged/_images/bg-header-public.jpg 2969d1b5f818325a7516ea392be9564e1da2a3e7expected: 42865291d24451e2dc7be44a60f3f692 got: 679bc6fd19e3879fed0c17e1b6735161

Here is what I did to verify the issue of the file

$ svn export -r1878 bg-header-public.jpg A bg-header-public.jpgExport complete.
$ openssl md5 bg-header-public.jpg MD5(bg-header-public.jpg)= 42865291d24451e2dc7be44a60f3f692
$ svn export -r1879 bg-header-public.jpg A bg-header-public.jpgExport complete.
$ openssl md5 bg-header-public.jpg MD5(bg-header-public.jpg)= 679bc6fd19e3879fed0c17e1b6735161
:_images ashah$ 

It is evident that the file has changed from r1878 to r1879, but while migrating the changes for 1878 why the changes of 1879 are showing up ? Or am i missing something here ?

+1 vote

There's a challenge that i'm currently facing after migration from WINCVS to GIT. The problem here is I need to pull/fetch a specific branch (and NOT clone the entire repository) from the repository to a particular location on the AIX server.

Earlier while using WINCVS this functionality was achievable using JCVSExport package as we could just checkout a particular branch and fetch the package on to the server location.
WINCVS Command : java JCVSExport -h -u abcde -p xxxxxx -d /abcd/cvs/testing -c "$REPOSITORY" -m "$PACKAGE"

I am not able to achieve the same functionality using GIT. I DO NOT want to clone the entire repository on the AIX server instead I just want to fetch/pull a specific branch contents on the server. Can someone please help me out with the solution or any possible way with which I can achieve the same functionality.

+1 vote

I would like to know why GIT calculates checksum of a file.Typically, checksum is used for the purpose of integrity. An example would really help.

+3 votes

When we clone a remote GIT repository, all folders/files will be cloned. This will consume lot of disk space in our local machine.
Is there a way to clone only few folders & exclude others?

This is possible in clearcase snapshot view by changing load rules.

Contact Us
+91 9880187415
#280, 3rd floor, 5th Main
6th Sector, HSR Layout
Karnataka INDIA.