That includes, say, file abc.txt, which you decided later had to be untracked. Well, that commit has whatever was in the index when you made it-whatever you had used git add to copy into the index. Let's suppose we have not actually run this command yet, and just consider: what will this do? What's in that commit? This tells Git: fill the index and work-tree from that very first commit. The index wasn't empty-it had F in it, along with everything else-it just matched the current commit, so most Git commands don't mention F until you've changed F in the work-tree.Ĭhecked out my very first commit from months ago: git checkout If you modify a file F and run git add F, the git add replaces the copy of the file that was (in Git format) in the index before. That's because you just checked out that commit, which put those files into both your index (in Git-only form, ready for the next commit) and your work-tree (in regular ordinary file form, ready for use or editing). Most of the time, it just matches your current commit. This means that it's very rare for your index to actually be empty. But the files in the index are changeable (unlike those inside commits) even though they're already converted to the special Git format. The index "sits in between" these two places: it has all your commit-able files, from your work-tree, all set to be committed. Files stored permanently and read-only in commits, inside the Git repository, have a special, compressed, Git-only format. Your work-tree is where you do your work: it has your files in their normal, non-Git format. This index, also called the staging area and the cache, keeps track of-i.e., indexes-your work-tree. The best one line description I have for the index is this: *The index is where you build your next commit to make.* Unfortunately, the index is very hard to see. Or, rather, it would be if it were clear what the index is. This definition is one of the few in Git that is simple and clear. Only untracked files are ignored: files are either tracked, untracked-but-not-ignored, or untracked-and-ignored.īut wait: what, precisely, is an untracked file? An untracked file is a file that is not in the index First, note that only untracked files are ignoredĪ file that is not untracked (that is tracked) is never ignored, even if a. Unfortunately, you'll have to spell them all out and fuss with Git a bunch, and you may get the wrong version. Fortunately, you should be able to get those files back-or at least some version of those files. This, plus one more thing, is (almost certainly) the source of the problem. gitignore at the first commit, but have been later added to it It seems that only files and foldes have disappeared that were not yet in the. Removing the file from main in the repo has fixed this issue.The stashed files have nothing to do with the disappeared files. env file was still on the main branch in the repo, and so every time I checked out to main and then checked out to another branch it would delete the file on the other branch for some reason. I'm not going to pretend to understand what was causing this or how exactly this was fixed, but it turns out the. gitignore and that also keeps getting removed.Įdit 2: Issue fixed. What am I doing wrong and how can I preserve this file in my local while having git ignore it?Įdit: The issue is not exclusive to this file, there is also a directory I have at the top-level of my project that is also in my. I've removed the file from the remote repo (originally it was committed) and cleared my git cache for all untracked files, but the file keeps getting deleted every time I switch branches. However, every time I checkout to a different branch on my local the file disappears and I have to keep making it. env file at the top-level of the project that is not meant to be tracked by git so it is inside of my.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |