0

Suppose I perform a git pull on the production server, and that one file has been changed.

Will the pull operation replace (or modify, or touch) all the files or just the changed file? The concern here is that I shouldn't replace files that are in use.

Clarification: The question isn't about potential merge conflicts or doubts thereabout. The question is strictly about whether git touches the other files.

5
  • I'd vote that it does NOT touch any unchanged files. As far as I know git's logic is that it detects which files has been changed and saves those files in commits and creates the difference and other things based on that. I am almost sure it does not store unchanged files. Commented Dec 14, 2021 at 10:30
  • 1
    It's better not to say git pull at all. Say git fetch and then look at the situation before merging. If you're in doubt of what's going to happen, commit (or stash) before merging. Why gamble? Commented Dec 14, 2021 at 13:53
  • 1
    @gazdagergo: every commit saves every file. The files are de-duplicated, so when the next commit has most of the files the same as the current commit, and the current commit has most of the files the same as the previous commit, all three snapshots are sharing most of their files. But each snapshot has a logical full copy of the file: it's just reduced to a shared physical copy. Commented Dec 14, 2021 at 18:45
  • 1
    Note that this de-duplication happens within a single commit as well: if you make 500 new files, each 10 MB long, each holding the same content, and commit that, you get a commit with 500 files in it, but all 500 files are shared, so that the commit uses only 10 MB even though all files are new. Commented Dec 14, 2021 at 18:46
  • 1
    What this all means is that you can't count on anything one way or another based on the internal storage design. Git does try, in various ways, to avoid rewriting files in the file system when possible, but it dosen't promise it won't overwrite a file with an identical copy. Commented Dec 14, 2021 at 18:47

1 Answer 1

1

Theoretically it will only touch the changed files.

But I have to discourage this kind of thing on a production server.

If for some reason you get a change on a dirty file causing a conflict you will after your pull be in an invalid state.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.