Search code examples
gitgit-rebasegit-commitgit-config

Fetch all the previous versions of any file committed in Git


I want to fetch all the previous versions of a file (let's assume Abc.xml) that I've committed in Git.

Is there any way to do so? I am sure Git has versioning system and so what I feel that my older file versions can be available. Any suggestions?


Solution

  • You can see the log of your file:

    git log -- myFile
    

    Or, for all branches:

    gitk --all -- myFile
    

    Then checkout (meaning replace in your current working tree) your file with any past version

    git checkout <commit> <file>
    

    Or simply see it with git show.

    I was getting error as : object file is empty

    Then check out: