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 9005345
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T01:07:12+00:00 2026-06-16T01:07:12+00:00

I am working on a project which has a bit of an uncommon behaving

  • 0

I am working on a project which has a bit of an uncommon behaving thing:

One of the files in the source code is a file that contains serious code, but it can edit itself to also include some configuration. Whether this is good design is a different discussion, but to be able to test my project, this file needs to be in its modified state.

Before I commit anything, I normally do an A-B comparison between the situation before and after my contribution. I use git stash to switch between base and my dirty working copy. The problem is that when using git stash, it also reverts my config-thing.

My current workaround is cumbersome: I do a git add path/to/settingsfile and then git stash --keep-index, but I rather dislike this workaround. Is there a more elegant solution to have git ignore all modifications to this file unless I specify otherwise?

  • 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-16T01:07:13+00:00Added an answer on June 16, 2026 at 1:07 am

    See ” Preserve git –assume-unchanged files between branch checkouts “

     git update-index --skip-worktree -- path
    

    That wouldn’t be reverted from a git stash.


    Original answer

    From “temporarily ignoring files “:

     git update-index --assume-unchanged <file>
    

    That would allow to ignore changes to that specific files.
    This won’t help if you want to revert code changes while keeping config changes in the same file though.

    And git stash will still revert it: How to prevent git stash dropping changes to files with the "assume unchanged" bit?


    Note that, before Git 2.25 (Q1 2020), “git stash save” in a working tree that is sparsely checked out mistakenly removed paths that are outside the area of interest.

    See commit 4a58c3d, commit 8dfb04a (30 Oct 2019) by Johannes Schindelin (dscho).
    (Merged by Junio C Hamano — gitster — in commit 57b5301, 10 Nov 2019)

    stash: handle staged changes in skip-worktree files correctly

    Signed-off-by: Johannes Schindelin

    When calling git stash while changes were staged for files that are marked with the skip-worktree bit (e.g. files that are excluded in a sparse checkout), the files are recorded as deleted instead.

    The reason is that git stash tries to construct the tree reflecting the worktree essentially by copying the index to a temporary one and then updating the files from the worktree.
    Crucially, it calls git diff-index to update also those files that are in the HEAD but have been unstaged in the index.

    However, when the temporary index is updated via git update-index --add --remove, skip-worktree entries mark the files as deleted by mistake.

    Let’s use the newly-introduced --ignore-skip-worktree-entries option of git update-index to prevent exactly this from happening.

    Note that the regression test case deliberately avoids replicating the scenario described above and instead tries to recreate just the symptom.

    Reported by Dan Thompson.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a project which I am working on and it has multiple files
I have a project which I am working on and it has multiple files
I've a project that I'm working on which has not been started by me.
I'm working on a project which contains several slave nodes and one master node.
I'm working on a project that has me a bit over my head performance-wise.
Can anyone help me find an up-to-date, working ATL project which has a main
I've just finished working for a client which has burnt millions on a project
Iam working on a project which involves writing a Mork File (Mork is a
We' re working on a project that has a relational object model and we
I'm working on a project which has a rich domain-model. Some of my classes

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.