Welcome to the CSC Q&A, on our server named in honor of Ada Lovelace. Write great code! Get help and give help!
It is our choices... that show what we truly are, far more than our abilities.

Categories

+20 votes

Every time I work on my laptop, push to GitHub, then pull to my working directory on my desktop I always get a bunch of .metadata files that say "Changes not staged for commit". I don't ever work on the project on my desktop, so none of the files should have been changed on that system. I usually just delete the project from my desktop and re-clone from github because I'm scared. Can someone tell me what's happening, and how to deal with it?

Changes not staged for commit:
  (use "git add/rm <file>..." to update what will be committed)
  (use "git restore <file>..." to discard changes in working directory)
        modified:   .metadata/.log
        modified:   .metadata/.plugins/org.eclipse.core.resources/.projects/.org.eclipse.egit.core.cmp/.location
        modified:   .metadata/.plugins/org.eclipse.core.resources/.root/.indexes/properties.index
        deleted:    .metadata/.plugins/org.eclipse.core.resources/.root/2.tree
        modified:   .metadata/.plugins/org.eclipse.core.resources/.safetable/org.eclipse.core.resources
        modified:   .metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.jdt.ui.prefs
        modified:   .metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.ui.ide.prefs
        modified:   .metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.ui.workbench.prefs
        modified:   .metadata/.plugins/org.eclipse.e4.workbench/workbench.xmi
        modified:   .metadata/.plugins/org.eclipse.m2e.logback.configuration/0.log
        modified:   .metadata/.plugins/org.eclipse.pde.core/.cache/clean-cache.properties
        modified:   .metadata/version.ini

Untracked files:
  (use "git add <file>..." to include in what will be committed)
        .metadata/.plugins/org.eclipse.core.resources/.root/3.tree
        .metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.jdt.core.prefs
        .metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.jdt.launching.prefs
        .metadata/.plugins/org.eclipse.jdt.launching/
asked in CSC305 Fall 2022 by (1 point)

2 Answers

+5 votes
 
Best answer

The .metadata folder is stored inside your Eclipse workspace, and Eclipse changes stuff in it every time you open Eclipse (and while Eclipse is open too).

Your Eclipse workspace should be kept separate from your git repo.

E.g. C:\git\AvocetRepo for your git repo
And C:\Users\elizabeth\workspace305 for your Eclipse workspace.

(You can import the existing projects from the git repo into your workspace, and it doesn't physically move the projects into the workspace folder -- the workspace just knows where to go looking for the project files.)

answered by (5.7k points)
selected by
+3 votes

You need to first stage the commits by using git add and git commit, then push.

answered by (1 point)
...