user1611830
user1611830

Reputation: 4857

Editing file using SHA - git

My question is perhaps very basic, but how do I edit a specific file from a version commit (whose author is a colleague working on the same remote repo as me) from which I know the SHA ?

Upvotes: 2

Views: 100

Answers (2)

bcmcfc
bcmcfc

Reputation: 26755

git checkout hashOfCommit path/to/file

You can then edit the file and commit your changes to the branch you are on currently.

Upvotes: 2

Denys Séguret
Denys Séguret

Reputation: 382130

If what you want is to get the content of the file, you can do

 git show someHash:pathToFile

If you want to see the differences between current version of the file with the one of the commit, you may do

 git diff someHash pathToFile

If you want to replace current version of the file with the one of the commit, you may do

 git reset --hard someHash pathToFile

Upvotes: 3

Related Questions