Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7954743
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T03:31:23+00:00 2026-06-04T03:31:23+00:00

In a git repository I have a subdirectory that I want to reset to

  • 0

In a git repository I have a subdirectory that I want to reset to a specific state in the past (an earlier commit). Is it possible to undo all commits on files in a specific subdirectory? I think there are no commits that apply changes to files within this subdirectory and on files located elsewhere at the same time. But it would be nice if it were possible to leave commits on files unaffected that are not located in this directory?

I don’t need to remove the history. It would be no problem to checkout the old state, remove the current content of the subdirectory, and copy and commit the old state in its place. But eventually there may be a more elegant (gitonic) way.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T03:31:25+00:00Added an answer on June 4, 2026 at 3:31 am

    The simplest way to do it to use the ability of git checkout to be applied on a subdirectory. Then stage and commit:

    git checkout <old-SHA1> -- path/to/subdir
    git add -A path/to/subdir
    git commit -m "reverted files in path/to/subdir to what it was at <old-SHA1>"
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a git repository that I'm trying to delete all files and folders
I have a Git repository that contains a bunch of top-level maven projects (each
I have a git repository, and a very old patch (made in 2007) that
I have git repository (powered by gitosis) on my local ubuntu server I want
Let's say I have multiple commits in my local git repository that have not
So I want to be able to back up a git repository that may
I have a git repository (and working directory) that is stored in my Dropbox
I have a GIT repository that I manage for my office. Because of company
I have a Git repository on my local machine that I cloned from my
I currently have a git repository that I imported from svn a while ago

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.