简体   繁体   中英

Can Windows VS Code run git commands via ssh on Ubuntu host connected to git repository

I don't know if this is possible, but I figured I'd ask.
I like developing on my Windows laptop, but to connect to our Git repository, we have to install all the tools on an Ubuntu host. In addition, the code I'm writing is for Linux, so I ultimately need to push it to the host for testing and then commit it via ssh at the command-line.

Is there any way such that VS Code can run the appropriate commands from my Windows laptop on the Ubuntu workstation to commit the code?

You can clone, modify and commit locally with your VSCode, then push through ssh to the remote repo on Linux.
It needs to be a bare repo .

git remote -v
auser@aLinuxMachine/a/path/to/remote/repo.git

You can then checkout the files of that bare repo to your actual folder on Linux.
Create a post-receive hook file (make it executable).

cat /a/path/to/remote/repo.git/hooks/post-receive

#!/bin/sh
unset GIT_INDEX_FILE
export GIT_WORK_TREE=/path/to/actual/files
export GIT_DIR=/a/path/to/remote/repo.git
git checkout -f

Once pushed you can run/test your code on Linux. Any Git operation can still be done locally on Windows.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM