Skip to main content

Git Known Issues

Branching

⚠️ When creating and pushing new branches on Linux, use command line. DO NOT use VS Code.

⚠️ When creating and pushing new branches on Windows, you can use command line or VS Code.

Pushing New Branches - Windows vs. Linux

In Windows, when you create a new branch and attempt to push your committed changes from command line, you will get a message to use the command git push --set-upstream origin new_branch. This will push your new local branch to the remote. When you push a new branch in VS Code, it likely does this command automatically behind the scenes.

In Linux, however, it does not hold your hand through the process. If you try to push a new branch, it won't give you a hint that you need to --set-upstream in the push command. Further, if you try to sync these changes in VS Code, it will try to push the changes to main/master.

Mac OS - Some Commits Untrack All Files

Dhananjay originally encountered this error on his personal Mac (Mac OS Sonoma 14.3.1). The following steps led to the error, but weren't completely reproducible. Sometimes the error occurred and sometimes it did not.

  1. Cloned a fresh copy of the <github.com/gqc/projects> repository.
  2. Made several commits.
  3. Eventually, one of the commits would seemingly trigger all files to become untracked (green in VS Code, need to add) as if in a completely empty repository.

While we don't know what caused this to happen, we did find some interesting artifacts in the local repository's ".git/" folder.

  • After the untracked bug occurs, a new file called "index 2" appears in the ".git/" directory.
  • This is in addition to the original "index" file. Each repository has an "index" file when it is cloned.
  • The index file in git controls the entire history of the git repository. It's what decides when files have changes, when the local is out of sync with the remote, and basically drives the whole functionality of git. You can find more information on the index file here: https://stackoverflow.com/questions/4084921/what-does-the-git-index-contain-exactly
  • The "index 2" file that appeared in Dhananjay's .git/ directory appears to take precedence over the default "index" that was also in the directory.
  • This "index 2" file was completely empty as if it were in a completely empty repository.
  • You can verify the file contents of the "index" file with the command git ls-files.
  • When we ran git ls-files after the "index 2" file appeared, we got an empty response.
  • When we flipped the names (renamed each) of "index" and "index 2", the git ls-files command returned the expected list of files.
  • Theoretically, deleting the "index 2" file should fix the issue as it occurs, but this isn't a permanent fix.

Dhananjay has upgraded his git from git version 2.39.2 (Apple Git-143) to git version 2.45.2 in an attempt to fix the problem.