Safest Option (exclude gitignored and uncommitted files):
git bundle create myreponame.bundle --all is safest, but it won't copy over ignored files in your .gitignore such as local config, IDE config, secrets, data, etc. It won't copy any uncommitted changes or files either.
Alternative Option (include gitignored and uncommitted files):
I recently migrated git repos from Windows to Linux (Ubuntu). This is the process I used to migrate dozens of git repositories which had lots of data, secrets, etc. that were ignored via .gitignore or recent code changes that weren't committed yet but I wanted to include in the migration anyways.
Directly copy the entire Git Repo from Windows to Linux
- Make sure to copy the entire git repo including the
.git folder - At this point, when I ran
git status on Linx, none of the files in the repo were being tracked
Run find . -type f -print0 | xargs -0 dos2unix on the repo in Linux.
- This will convert all the line endings from Windows format (CRLF) to Linux format (LF).
- Make sure to include the
.git folder when you run this command
Run git add .
- This will allow git to track all files again. Usually, the repo is bugged and will show all files as being untracked when you first copy it to Linux.
Run git restore --staged .
- This is the final step. It will restore the git repo to the exact status you left it in on Windows. When you do git add in the step above, it adds every file that's not ignored in .gitignore. However, that means that some uncommitted files or uncommitted changes will also be added. By running git restore, you untrack these changes and bring the repo back to it's original state.
That's all you need to do to migrate a git repo from Windows to Linux!