Ignore specific changes to a file in git, but not the entire file

前端 未结 9 1812
春和景丽
春和景丽 2020-12-28 12:14

I have a file in a git repository that has a local change on it. I want to have git ignore the local change forever, but not the file. In particular,

  • If the fi
9条回答
  •  一个人的身影
    2020-12-28 12:46

    As of Git 2.5 (July 2015), you can use git worktree:

    git worktree add -b patch-1 ../patch-1
    

    This is essentially just creating a branch, but it puts the new branch into a new folder alongside the parent repo. This is nice because you can do work on this branch, even without committing, then switch back to master with a clean working directory.

提交回复
热议问题