简体   繁体   中英

How to get a specific commit of a particular folder from a git repository while keeping rest of the folders as latest?

Following is the exact scenario in my repository:

Folders:

  • Respository
    • Project A
    • Project B

Developers are working on both the projects. After a while, we realized that we the developers have committed some unwanted and unexpected code in Project B. Now we need to rollback Project B to a specific commit (say, "ai298349y") and the developers are expected to work on that, while we want Project A to its current state (ie, latest commit)

How can I achieve this in Git?

I am using Git extension in visual studio. Can anyone please suggest?

Well, basically you should use different Git repositories for different projects and not follow the SVN craziness of stuffing multiple repositories into one SVN root.

You cannot reset project B independently, eradicating the faulty commits now without affecting project A if that would have been what you were after.

What you should do is git rm -rf projectB && git checkout ai298349y -- projectB && git add projectB && git commit -m 'revert project B to good state' which will simply result in a new commit that undoes the faulty changes in projectB with a new commit.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM