I'm working on a project in both Ubuntu WSL and Windows 10. I want to be able to edit the files in both windows 10 files system via sublime/...and in Ubuntu WSL via VScode/...and push changes to remote. I have noticed 2 issues when doing this:
What should I do such that editing and pushing changes across windows filesystem and WSL filesystem retains the same mode?
Right now, I'm experimenting with using the below command every time I do a change via windows.
git add . --chmod=+x
(source: How to create file execute mode permissions in Git on Windows?) Is there a better way to handle this situation?
- print('hello')
+ print('hello')
I'm not sure why this happens.
I'm still learning Git and would like to know if what I'm doing is correct or if there are better ways to handle editing the same repo from different file systems.
If you're storing a repository on a Windows file system, then it doesn't preserve Unix executable bits, and you'll need to rely on the --chmod
flag to set those permission accordingly. If you store it only on a Linux file system and use the \\$wsl
path notation under Windows, then the permissions will be preserved if (a) you stick to using the Linux Git binary and (b) your editor writes over existing files instead of writing to the side and renaming over the old one.
The reason you're seeing all the lines being modified is because one of your editors (probably the Windows one) is writing Windows line endings (CRLF) and the other is writing Unix line endings (LF). If you create a file in your repository called .gitattributes
with the line * text=auto
, then that will cause all the text files in your repository to be normalized with LF line endings when they're committed, which is generally what you want.