Is there a command in Git to see (either dumped to stdout, or in $PAGER
or $EDITOR
) a particular version of a particular file?
To be efficient, if files have not changed, Git doesn't store the file again—just a link to the previous identical file it has already stored. This is an important distinction between Git and nearly all other VCSs.
Git file History provides information about the commit history associated with a file. To use it: Go to your project's Repository > Files. In the upper right corner, select History.
Reverting To An Old Version of the Repository Start by navigating to the “History” tab. Right-click on the previous commit, and you'll see the option to revert this commit. If you click on Revert This Commit , two things will happen. The first is that the files in your repository will revert to their previous state.
2.1 git log to display all the commit_id, the first one is the last commit_id, copy it. 2.2 git show commit_id --name-only to display all the files committed in the specified commit_id. 2.3 Undo the last commit with git reset --soft HEAD~1 , move the mistakenly committed files back to the staging area.
You can use git show
with a path from the root of the repository (./
or ../
for relative pathing):
$ git show REVISION:path/to/file
Replace REVISION
with your actual revision (could be a Git commit SHA, a tag name, a branch name, a relative commit name, or any other way of identifying a commit in Git)
For example, to view the version of file <repository-root>/src/main.c
from 4 commits ago, use:
$ git show HEAD~4:src/main.c
Git for Windows requires forward slashes even in paths relative to the current directory. For more information, check out the man page for git-show
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With