0

I'd like to change the files locally, but still have the ability to keep those updates in case others on my team make important changes. However, I would like to be able to choose that all changes can be committed and not exclude the extra files every time. Is there a possibility?

With .gitignore and with exclude, the file would unfortunately not get any updates.

Before that I worked with SVN and there was a section with ignore-on-commit. Is there something like that with Git?

mkrieger1
  • 19,194
  • 5
  • 54
  • 65
Tiri
  • 1
  • 1
    I don't understand how what you are trying to do is different from just adding a file to Git and not ignoring it. Do you mean that you do not want to *share* your local changes with others? – mkrieger1 Jan 18 '22 at 09:36
  • First, all changes are local, you are not refactoring code on the github server when you type on your computer. To your question; when you type `git add .` you actually add all the documents/files/folders in the current directory that passes the `.gitignore`. You can selectively upload just one folder/script with `git add 'your_folder'` – Sy Ker Jan 18 '22 at 09:36
  • If you want to keep the local files when using `git pull` you have to 'stash' your local modifications and than re-apply them using `git stash; git pull; git stash pop`. – Sy Ker Jan 18 '22 at 09:42
  • 1
    Would this do the trick? https://stackoverflow.com/questions/10755655/git-ignore-tracked-files – toniedzwiedz Jan 18 '22 at 09:44
  • Do I understand this right that you want to: * Have the files not be automatically added when you do `git add -A` or the likes. * But still get a merge when you pull changes to them ? So basically the files should just stay as tracked and modified but unstaged? What should happen when you pull a change? – lucidbrot Jan 18 '22 at 09:50

1 Answers1

0

You are looking for git update-index --assume-unchanged:

When the "assume unchanged" bit is on, the user ... allows Git to assume that the working tree file matches what is recorded in the index.

SebDieBln
  • 3,303
  • 1
  • 7
  • 21
  • 1
    He probably wants `--skip-worktree`, but the effects of the two flags are the same most of the time, so this may be a distinction without a difference here. :-) More importantly (to @Tiri): once you *set* this flag, you'll need to remember that you *did set it*, and you will need to *clear* the flag later. You can get work done this way, it's just a pain. – torek Jan 18 '22 at 21:47