0

I have 2 branches, A and B, and both were created from master. On A I created a file FileA, did some commits, pushed to remote. While that's in PR, I swapped to B, created a new file FileB and did some work; however all I did was add it to Git, it hasn't had a commit yet.

In IntelliJ, when I swapped back to A to do some fix for the PR, File B appears in the project tree and inside the commit window. Why is that? How to resolve this?

  • Git won't delete untracked files if you switch branches. You can create a local commit on branch `B`, then the file will stay there. – Jan Wilamowski Jun 08 '22 at 02:39
  • @JanWilamowski worked perfectly; do you perhaps have any type of documentation explaining this in more detail? –  Jun 08 '22 at 02:42
  • how about https://git-scm.com/docs/git-switch/2.23.0: "Switching branches does not require a clean index and working tree (i.e. no differences compared to HEAD). The operation is aborted however if the operation leads to loss of local changes, unless told otherwise with --discard-changes or --merge." – Jan Wilamowski Jun 08 '22 at 02:50

0 Answers0