Skip to main content
  1. Data Science Blog/

Working with GitHub from WSL and Windows Folders

·946 words·5 mins· loading · ·
Version Control GitHub Software Development Development Environment & Tools GitHub Development Environment Operating Systems Version Control Collaboration Tools

On This Page

Table of Contents
Share with :

Working with GitHub from WSL and Windows Folders

Problem Statement:
#

I have project in D:\github-blog\dasarpai-websitetest. This is also a github repo. It’s remote repo is https://github.com/dasarpai/dasarpai-websitetest. I have github desktop for windows 11 installed on my machine. Sometime I push/pull files in github repo using this github desktop. I have Visual Code IDE installed on my windows 11 machine and I also visual code IDE on my machine’s wsl.

When I am working with this project from windows 11 or wsl then sometimes file will get updated.

Keeping all this in mind do you have anything for me which I need to take care of github repo code.

Solution Space
#

Given your setup with the dasarpai-websitetest project, GitHub Desktop, Visual Studio Code (VS Code) on Windows 11, and VS Code on WSL, along with pushing/pulling files to/from the GitHub remote repository, here are some tips and considerations to ensure smooth management of your GitHub repo code:


1. Syncing Between Windows 11 and WSL
#

Since you’re working on the same project from both Windows 11 and WSL, there’s a risk of file conflicts or inconsistencies. Here’s what to watch out for:

  • File Path Differences: Windows uses backslashes (\) and drive letters (e.g., D:\), while WSL uses Unix-style paths (e.g., /mnt/d/). Ensure your Git repository is accessible consistently. It’s best to work on the project from a directory that both systems can access seamlessly, like D:\github-blog\dasarpai-websitetest, which WSL maps as /mnt/d/github-blog/dasarpai-websitetest.

    • Tip: Open the project in WSL using VS Code’s WSL extension (Remote - WSL) to avoid path confusion.
  • Line Endings (CRLF vs LF): Windows uses CRLF (carriage return + line feed) for line endings, while WSL/Linux uses LF (line feed). This can cause Git to detect changes in files even if you didn’t modify them.

    • Fix: Configure Git to handle line endings consistently:
      git config --global core.autocrlf true  # On Windows
      git config --global core.autocrlf input # On WSL
      
      Alternatively, add a .gitattributes file to your repo:
      * text=auto
      
  • File Permissions: WSL might alter file permissions in a way that Windows doesn’t recognize properly. This usually isn’t an issue for Git unless you’re tracking executable scripts.

    • Tip: Avoid committing permission changes unless necessary (e.g., use git config core.fileMode false in WSL).

2. Using GitHub Desktop and VS Code Together
#

You’re using GitHub Desktop for push/pull operations, but you might also use Git commands in VS Code (via its terminal or Git integration). Here’s how to avoid confusion:

  • Check Git Status Before Switching Tools: If you make changes in VS Code (Windows or WSL) and then switch to GitHub Desktop, ensure there are no uncommitted changes. Run git status in the terminal or check the Git panel in VS Code.
  • Commit Frequently: Whether in GitHub Desktop or VS Code, commit changes often with meaningful messages to avoid losing work or creating large, unwieldy commits.
  • Pull Before Push: Always pull from the remote repo (https://github.com/dasarpai/dasarpai-websitetest) before pushing, especially if you switch between Windows and WSL. GitHub Desktop usually prompts for this, but double-check in VS Code if you use its Git features.

3. Avoiding Conflicts in the Repo
#

Since files “sometimes get updated” when working in Windows or WSL, you might accidentally overwrite changes or create merge conflicts. Here’s how to manage this:

  • Branching Strategy: If you’re experimenting or working on features, create separate branches (git checkout -b feature-name) instead of working directly on main. This keeps your main branch stable.

    • Example:
      git checkout -b wsl-updates  # Work in WSL
      git checkout -b windows-updates  # Work in Windows
      
      Merge them later with git merge.
  • Stash Changes: If you switch between Windows and WSL mid-work, use git stash to temporarily save uncommitted changes:

    git stash  # Save changes
    git pull   # Update from remote
    git stash pop  # Reapply changes
    
  • Sync Regularly: Use GitHub Desktop or git pull to keep your local repo in sync with the remote repo before starting work in either environment.


4. Tool-Specific Tips
#

  • GitHub Desktop:

    • Use it for simple push/pull operations, but if you encounter merge conflicts, resolve them in VS Code or the terminal since GitHub Desktop’s conflict resolution is limited.
    • Check the “History” tab to ensure your commits align with what’s on the remote repo.
  • VS Code (Windows):

    • Use the built-in Git integration (Source Control tab) to stage, commit, and push changes if you prefer a GUI over GitHub Desktop.
    • Install the “GitLens” extension for better Git history and blame tracking.
  • VS Code (WSL):

    • Ensure your WSL distro has Git installed (sudo apt install git for Ubuntu-based distros).
    • Use the WSL terminal in VS Code for Git commands if you’re working in the WSL environment.

5. Backup and Safety
#

  • Remote as Backup: Since your repo is on GitHub, it’s already a good backup. Push changes frequently to avoid losing work if something goes wrong locally.
  • gitignore: Ensure you have a .gitignore file to exclude unnecessary files (e.g., build artifacts, IDE configs like .vscode/, or WSL-specific files). Example:
    node_modules/
    .vscode/
    *.log
    

6. General Workflow Suggestion
#

Here’s a streamlined approach:

  1. Start your session by opening D:\github-blog\dasarpai-websitetest in VS Code (Windows or WSL).
  2. Run git pull (or use GitHub Desktop) to get the latest changes from https://github.com/dasarpai/dasarpai-websitetest.
  3. Make your changes and test them.
  4. Stage and commit your changes (git add . and git commit -m "your message" in VS Code, or use GitHub Desktop).
  5. Push to the remote repo (git push or GitHub Desktop’s “Push” button).
  6. Repeat when switching between Windows and WSL.

Final Notes
#

This setup is fairly standard, and with a little care, you can avoid most issues. The key is to stay consistent with how you interact with Git (e.g., pull before editing, commit often) and be mindful of the Windows-WSL differences.

Dr. Hari Thapliyaal's avatar

Dr. Hari Thapliyaal

Dr. Hari Thapliyal is a seasoned professional and prolific blogger with a multifaceted background that spans the realms of Data Science, Project Management, and Advait-Vedanta Philosophy. Holding a Doctorate in AI/NLP from SSBM (Geneva, Switzerland), Hari has earned Master's degrees in Computers, Business Management, Data Science, and Economics, reflecting his dedication to continuous learning and a diverse skill set. With over three decades of experience in management and leadership, Hari has proven expertise in training, consulting, and coaching within the technology sector. His extensive 16+ years in all phases of software product development are complemented by a decade-long focus on course design, training, coaching, and consulting in Project Management. In the dynamic field of Data Science, Hari stands out with more than three years of hands-on experience in software development, training course development, training, and mentoring professionals. His areas of specialization include Data Science, AI, Computer Vision, NLP, complex machine learning algorithms, statistical modeling, pattern identification, and extraction of valuable insights. Hari's professional journey showcases his diverse experience in planning and executing multiple types of projects. He excels in driving stakeholders to identify and resolve business problems, consistently delivering excellent results. Beyond the professional sphere, Hari finds solace in long meditation, often seeking secluded places or immersing himself in the embrace of nature.

Comments:

Share with :

Related

What is a Digital Twin?
·805 words·4 mins· loading
Industry Applications Technology Trends & Future Computer Vision (CV) Digital Twin Internet of Things (IoT) Manufacturing Technology Artificial Intelligence (AI) Graphics
What is a digital twin? # A digital twin is a virtual representation of a real-world entity or …
Frequencies in Time and Space: Understanding Nyquist Theorem & its Applications
·4103 words·20 mins· loading
Data Analysis & Visualization Computer Vision (CV) Mathematics Signal Processing Space Exploration Statistics
Applications of Nyquists theorem # Can the Nyquist-Shannon sampling theorem applies to light …
The Real Story of Nyquist, Shannon, and the Science of Sampling
·1146 words·6 mins· loading
Technology Trends & Future Interdisciplinary Topics Signal Processing Remove Statistics Technology Concepts
The Story of Nyquist, Shannon, and the Science of Sampling # In the early days of the 20th century, …
BitNet b1.58-2B4T: Revolutionary Binary Neural Network for Efficient AI
·2637 words·13 mins· loading
AI/ML Models Artificial Intelligence (AI) AI Hardware & Infrastructure Neural Network Architectures AI Model Optimization Language Models (LLMs) Business Concepts Data Privacy Remove
Archive Paper Link BitNet b1.58-2B4T: The Future of Efficient AI Processing # A History of 1 bit …
Ollama Setup and Running Models
·1753 words·9 mins· loading
AI and NLP Ollama Models Ollama Large Language Models Local Models Cost Effective AI Models
Ollama: Running Large Language Models Locally # The landscape of Artificial Intelligence (AI) and …