I am using Windows to do some Linux development with WSL.
When I add Linux repositories to GitHub, it recognizes them, but it gets confused with file names and line endings between Linux and Windows.
This doesn't happen on the terminal tools inside git > Ubuntu > WSL, but it does happen on git > Windows.
Is there a way to either run GitHub Desktop's GUI on Ubuntu within WSL or to make the Windows version run its internal git commands through WSL's bash? Maybe a git configuration in Windows to make it Linux-aware?
I use this repo https://github.com/andy-5/wslgit
With this, you can use the linux git from windows.
To make it work with Github Desktop you have to replace the git it uses, it is in the folder C:\ProgramData\User\GitHubDesktop\app-2.9.12\resources\app\git\cmd
Be careful because it changes every time Github Desktop is updated and you have to change it again.
The git used by Github Desktop is different from the linux one and sometimes some errors come out, I have had to install the git-lfs and git-core packages.
Related
I want to get started developing my own packages. I am also adding version control via Github. I mainly develop on my Mac and a Windows laptop, but there is potential for me to develop on other machines down the line. My IDE of choice is PyCharm. I need to figure out where to place my packages both on Github and on my local machines so that my packages are always in sync regardless of where I am developing. Help??
First, let's clarify that git is the version control system, and Github is a platform for hosting git repositories (there are many other platforms aside from Github). You use git commands to manage your codes, and Github is where you store a copy of your codes.
By adding version control and putting a copy on Github, you've already taken the first step in managing your codes on different machines. All you need to do is to make sure the codes on Github is always the latest updated or maintained version.
Here's a sample workflow:
On machine 1 (Mac), clone a copy of the Github repo
Develop on machine 1
When you are satisfied with your changes, push your codes from machine 1 to Github
On machine 2 (Windows), clone a copy of the Github repo
Develop on machine 2
When you are satisfied with your changes, push your codes from machine 2 to Github
On machine 1, do a fetch to check for updates to the code
If there are updates, pull those changes to machine 1
Again, when done making changes, push them from machine 1 to Github
On machine 2 again, fetch and pull changes
Repeat this fetch-pull-push- cycle for all machines
Basically, you'll need to make sure that on wherever machine you are, when you are done, you should always push those changes to the remote (Github). So that other machines, can fetch and pull those changes and continue where you left off.
UPDATE (based on comment):
Once you've got the workflow for your package source codes, next is to package them like any other regular Python package and install them to your site-packages (either directly for your system or preferably in a virtual environment).
I recommend taking a look at the Python docs on Packaging Python Projects which uses setuptools to make your package compatible with pip.
Here's a sample workflow:
git clone <mypackage#github.com> # or git pull if you already cloned it before
cd mypackage
pip install -r requirements.txt
pip install -e . or pip install --user -e .
That last step will install your package to your site-packages folder, like any other pip-compatible package (assuming you've setup your setup.py file properly). If you are using virtual environments, you'll have to activate the virtual env first, then install your package there.
If you are not going to do any modification on the source code, and you just want to install the package on a specific machine, then you can also specify the Github URL to pip:
$ pip install -e git+https://git.repo/some_pkg.git#egg=SomeProject # from git
Lastly, if you are planning to upload this package to PyPi, check out the docs on Uploading the distribution archives. This just adds an extra step to your workflow of uploading your package to PyPi and then doing pip install from there next time.
I have setup WSL (Windows Subsystem for Linux) on Windows 10 and installed Anaconda with python 3 and jupyter lab included.
When launching Jupyter lab, I am asked to copy paste http://localhost:8888/lab in my browser, and that works fine.
However, I don't know how to access to all my notebooks stored in Windows, I can't browse Windows through Jupyter Lab.
I have searched in Google but can't find the answer.
Does anyone have an idea on how I can browse my notebooks folder stored in Windows?
Juggling files between different environments can be a big productivity killer, as you are already finding out. A potential approach would be to:
Organize your files on your local PC into a repository using github.com or equivalent, and pushing those files to your account.
Open a new terminal window in your Jupyter Lab, and pull the repo, substituting your name and email:
$ sudo apt install git
$ git config --global user.name "username"
$ git config --global user.email "email"
$ git init
$ git clone
If you are not already doing, so it may also help you to use a conda environment, and add the spec file to your github repo so that you always know conda environment specification regardless if you are in windows or WSL (or on another server altogether).
$ conda list --explicit > spec-file.txt
$ git add spec-file.txt
$ git commit -m "added spec file for conda environment"
If you installed jupyter using conda, then your conda environment should be 'selectable' within Jupyter Lab, but if not, there are other posts on stackoverflow that show how to configure Jupyter Lab to make sure you can select your various conda environments.
Create config file:
jupyter notebook --generate-config
Edit it with text redactor:
nano ~/.jupyter/jupyter_notebook_config.py
Set desired starting directory:
c.NotebookApp.notebook_dir = '/mnt/c/Users/Username/Path'
I would like to use WSL (Bash on Windows) Git with VSCode instead of Git for Windows to avoid multiple Git installations.
I created a simple bat script to emulate git.exe comportment by redirecting git commands in WSL. It works nicely in CMD but not with VSCode. Also, WSL is my default terminal in VSCode.
VSCode settings.json:
{
"git.path": "D:\\tools\\git.bat",
"terminal.integrated.shell.windows": "C:\\Windows\\Sysnative\\bash.exe"
}
and git.bat:
#echo off
bash -c 'git %*'
Any idea to make VSCode working with WSL Git ?
Since VS Code 1.34 (April 2019) a remote extension has been introduced to develop into WSL: https://code.visualstudio.com/docs/remote/wsl.
Basically, a server instance of VS Code is started into WSL, allowing you to use all the WSL tools (e.g. git) from your client instance on Windows.
Thank you for pointing that out #Noornashriq Masnon!
I created a small tool to solve this for myself, and hosted it on GitHub.
Basic git functionality seems to work, like viewing changes and committing.
A ready-to-use binary can be downloaded from the Releases page.
One of the problems is that the input paths need to be translated from the Windows representation (C:\Foo\Bar) to the Linux paths in WSL (/mnt/c/Foo/Bar), and back again for paths in the output of git.
For example, the Git plugin in VSCode uses the command
git rev-parse --show-toplevel
to find the root directory of the git repository, but with WSL git this of course returns a Linux path that needs to be translated for VSCode on Windows.
Provide the full path for the bash exec :
git.bat :
#echo off
c:\windows\sysnative\bash.exe -c "git %*"
What you can do is to first try wslpath and if that fails you try a normal git command. It's not ideal but it works.
See: Use WSL git inside VS Code from Windows 10 17046
On Windows 8 & trying to use SourceTree as my Git client -- all works but the following:
When I hit the terminal button in Sourctree it says "It has not been possible to start the Git Bash terminal" (yes, I'm using the default SourceTree setting to launch the git bash terminal when this button is clicked).
I am able to bring up said terminal but then I have to cd into the proper directory. Really would like the terminal button to work in SourcTree.
Yeah, for me the solution was to upgrade GIT to newest version. I had 1.9.4 and now I have 2.6.3. It works great. Also I noticed that git has new console right now, I see more colors here :)
Check your git version. If you still have system Git 1.9.5 running, then better upgrade to 2.6.3 now. Check your Git Path too then restart SourceTree. The new git bash terminal looks like this:
This may be useful if Cygwin is installed.
Thanks for suggesting to upgrade Git, but it didn't resolve the issue for me on Windows 7.
To find out Git's location, open a new Git Bash and invoke the which git command:
$ "which git"
/usr/bin/git
Remove git.exe from C:\cygwin\bin.
Restarted SourceTree and it worked.
I am setting up a development environment in my home. I have installed a centos linux in a virtual machine. All files in /var/www/html are shared with samba.
I have access to these files in windows. I have installed git in centos. I created a git repository in a sub directory of /var/www/html.
I am using Eclipse in windows. Egit is installed in Eclipse. I tried to add repository in eclipse but when I do a commit in egit, "git status" in linux displays a list of modified files to commit. Also when I do a commit in linux, all files in egit will be marked az modified.
I don't know how to synchronize egit with git. What is the correct way to do this?
The easiest solution by far would be to use a cloud service such as GitHub (or BitBucket if you want free private repositories).
An example workflow is (on terminal, however your clients will have GUI options for this):
$ git remote add origin git#bitbucket.org:username/repository
$ git push origin master
The on your other client fetch the changes and merge them in through pull
$ git pull
Both sides will need to have the same remote repository - This way you can push - pull wherever you do the work and the code be the same. I use this setup for developing and deploying my web-apps.
This solution relies on you having an internet connection - if you dont want or dont have an internet connection at your disposal then have a look at this post:
gitosis vs gitolite?