Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to checkout old version of folder in git

Tags:

git

I need to pull changes from origin. Problem is that one of libs was updated to newest version and it crashes my part of application. I would like to pull recent changes and then go back to previous (or specific) version for only one folder, which contains that problem causing lib. Is there any way to do that?

like image 457
solgar Avatar asked Feb 12 '13 09:02

solgar


Video Answer


2 Answers

git checkout LAST_WORKING_COMMIT -- vendor/library/in/question

This will check out the folder in the version of LAST_WORKING_COMMIT. However, git status will then tell, that the files are modified:

$ git status
# On branch master
# Changes not staged for commit:
#   (use "git add <file>..." to update what will be committed)
#   (use "git checkout -- <file>..." to discard changes in working directory)
#
#       modified:   vendor/library/in/question/file.exe
#
no changes added to commit (use "git add" and/or "git commit -a")
like image 173
Boldewyn Avatar answered Oct 14 '22 17:10

Boldewyn


Use an additional argument to git checkout:

git checkout REV -- folder
like image 26
user4815162342 Avatar answered Oct 14 '22 17:10

user4815162342