Introduction
Recently, I moved my development environment from Ubuntu 26.04 to Windows 11 Pro. On Ubuntu, I was comfortable working with Git, managing branches, committing changes, and switching between different branches.
However, after moving my Laravel project to Windows 11, I started experiencing difficulties switching between branches.
I was working on a project called SamuPOS, and I wanted to switch from my vincent branch to main. What I thought would be a simple Git operation turned into an interesting troubleshooting experience.
I decided to share this experience because beginners and developers working across different operating systems might encounter similar problems.
1. Understanding my Git branches
Before troubleshooting, I wanted to establish whether my local and remote branches were configured correctly.
I executed:
git branch Git returned:
fixing-api-request main * vincent This showed that I had three local branches:
fixing-api-requestmainvincent
The asterisk (*) indicated that I was currently working on the vincent branch.
Next, I checked my remote branches:
git branch -r Output:
origin/HEAD -> origin/main origin/fixing-api-request origin/main origin/vincent This confirmed that the branches also existed on GitHub.
At this point, I initially thought everything was correctly configured.
2. My first attempt to switch branches
I tried switching to main:
git switch main Unfortunately, Git returned an error:
error: The following untracked working tree files would be removed by checkout: tests/Feature/MenuCategoryMigrationTest.php Please move or remove them before you switch branches. Aborting This was my first indication that the problem was not necessarily related to the branch configuration.
Git was protecting my local files because switching branches could overwrite an untracked file.
What does this error mean?
Git prevents you from switching branches when doing so could overwrite files that are not safely tracked in the current working directory.
This protection is important because Git does not want you to accidentally lose your work.
3. Checking my Git working directory
Instead of forcing the branch switch, I checked the current repository status:
git status The output showed:
Changes to be committed: deleted: IlluminateFoundationComposerScripts::postAutoloadDump deleted: tests/Feature/MenuCategoryMigrationTest.php This was interesting because Git showed two files staged for deletion.
I also checked the tracking information for my branches:
git branch -vv Output:
fixing-api-request 64b9a9c [origin/fixing-api-request] corrected MenuCategory model main 2af1e97 [origin/main] Merge branch 'vincent' into main * vincent b3cad01 [origin/vincent] updating controllers to remove duplicates This confirmed that my local branches were already tracking their respective remote branches.
Therefore, the issue was not simply that my local main branch was disconnected from GitHub.
4. Attempting to use Git stash
My next step was to temporarily save my uncommitted changes.
I used:
git stash push -u -m "Backup vincent changes before switching to main" The -u option is important because it tells Git to include untracked files in the stash.
However, I encountered another unexpected error:
Ignoring path IlluminateFoundationComposerScripts::postAutoloadDump Saved working directory and index state On vincent: Backup vincent changes before switching to main error: invalid path 'IlluminateFoundationComposerScripts::postAutoloadDump' fatal: Could not reset index file to revision 'HEAD'. This revealed a deeper problem.
5. The unexpected Windows filename compatibility issue
The problematic filename was:
IlluminateFoundationComposerScripts::postAutoloadDump Notice the double colon (::) in the filename.
This is where my transition from Ubuntu to Windows became particularly interesting.
Linux filesystems generally permit colons in filenames, whereas Windows normally prohibits colons in ordinary filenames.
Some of the characters Windows does not permit in ordinary filenames include:
< > : " / \ | ? * This means a repository that works perfectly well on Ubuntu can encounter filesystem compatibility problems when checked out on Windows.
Git was struggling to handle the filename because Windows could not represent it normally.
This was an important lesson: Git is cross-platform, but not every filename supported by one operating system is compatible with another.
6. Investigating my Git stash
I wanted to establish whether my previous stash operations had actually saved my changes.
I executed:
git stash list Git returned:
stash@{0}: On vincent: Backup vincent changes before switching to main stash@{1}: On vincent: Temporary changes before switching to main stash@{2}: On vincent: saving local changes before switching to main stash@{3}: WIP on main: 2af1e97 Merge branch 'vincent' into main stash@{4}: WIP on vincent: 5802eb8 Add Swagger API docs with basic auth and ignore .claude This showed that I had accumulated several stash entries from my previous attempts.
I also inspected the latest stash:
git stash show --stat 'stash@{0}' The output showed:
...nateFoundationComposerScripts::postAutoloadDump | 0 tests/Feature/MenuCategoryMigrationTest.php | 33 ++++++++-------------- Although the stash entry existed, the earlier error indicated that the stash operation had not completed cleanly.
This taught me another important lesson: seeing a stash entry does not automatically mean every part of the stash operation completed successfully.
Always inspect your repository status and stash contents before assuming your work is safely restored or saved.
7. What finally helped me move forward?
After several troubleshooting attempts, I decided to commit my changes remotely to GitHub.
This helped resolve the immediate working-tree conflicts, allowing me to move forward with my branch-switching problem.
The experience reminded me why regularly committing changes is important.
Instead of relying entirely on local modifications or multiple stash entries, I had a committed version of my work available remotely.
However, committing changes does not automatically fix every Windows filename compatibility issue. Such filenames should still be investigated and corrected if they are part of the repository.
8. Important Git commands I learned and used
Here are the commands that helped me investigate the problem.
| Command | Purpose |
|---|---|
git branch | Lists local branches |
git branch -r | Lists remote branches |
git branch -vv | Shows branch tracking information |
git status | Shows the current working-tree state |
git switch main | Switches to the main branch |
git stash push -u -m "message" | Stashes tracked and untracked changes |
git stash list | Lists saved stash entries |
git stash show --stat 'stash@{0}' | Displays a summary of the latest stash |
git pull origin main | Fetches and integrates remote main changes |
9. Lessons for developers working across Ubuntu and Windows
This experience taught me several practical lessons.
1. Understand your working directory before switching branches.
Always execute:
git status This helps you identify uncommitted changes before performing Git operations.
2. Be careful with untracked files.
Git protects untracked files from being overwritten during branch switching. Do not immediately delete them just to make a branch switch work.
3. Understand the difference between Git stash and Git commit.
Stash temporarily stores local changes, while a commit records a snapshot in your repository's history.
Both are useful, but they serve different purposes.
4. Consider filesystem compatibility.
When developing across Linux and Windows, avoid filenames containing characters that are prohibited by Windows.
5. Do not use destructive Git commands blindly.
Commands such as:
git reset --hard git stash clear can result in losing work if you do not understand their effects.
Always investigate first.
Conclusion
Moving from Ubuntu 26.04 to Windows 11 Pro was supposed to be a straightforward change of development environment. However, my experience with SamuPOS reminded me that different operating systems can introduce unexpected development challenges.
What started as a simple attempt to switch from vincent to main became an opportunity to understand Git's working-tree protection, branch tracking, stash operations, and filesystem compatibility.
For beginners, my biggest takeaway is this:
Before blaming Git, check your working directory, understand the error message, and investigate the files involved.
Sometimes the problem is not your Git commands but the environment in which you are running them.
