How to use SSH credentials and GPG for dev container in vscode? - visual-studio-code

I am using VScode on macOS and are exploring dev containers to use for development to encapsulate all dependencies required to build my Go project. I created a dev container from my existing local Git repository and installed Ubuntu with Python and Go dependencies.
If I understand correctly, but local Git repository will be obsolete and my entire project will be moved into a container. How do I setup Git in that case? it is installed but doesn't have access to my local ~/.ssh or ~/.gnupg directory.
The VScode documentation has a page called Sharing Git credentials with your container and states it should work out of the box:
The Dev Containers extension provides out of the box support for using local Git credentials from inside a container. In this section, we'll walk through the two supported options.
My local .gitconfig has set user, email and signingkey. Still a push and pull within the container leads to:
git#github.com: Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
Can anyone help me?

Related

Setting up Weblate to create pull requests

I want to use Weblate to help with the localization of an open source project that is developed on GitHub. I don't have write access to the repositories of the maintainers and have to submit pull requests for the improvements I make. It look as if Weblate supports creating pull requests, but I can't get it to work.
What I've done so far:
Run Weblate 3.4 (in a Docker container) and setup the SSH keys for GitHub access.
Set Docker environment variable WEBLATE_GITHUB_USERNAME to my GitHub username.
Opened a shell session in the Docker container and run hub clone octocat/Spoon-Knife (both as root and the weblate user; this asks for username and password and the clones the repository; the token is also still there after I restart the Docker containers)
Set up a Weblate project.
Set up a component in the project.
Source code repository = upstream GitHub repo (git#github.com:maintainer/repo)
Repository branch = master
Repository push URL = my forked GitHub repo (git#github.com:me/repo)
Version Control System: GitHub (EDIT: added on Feb 10 2019)
EDIT (Feb 10 2019):
After finding out that you have to specify "GitHub" as Version Control System when creating a component, Weblate now tries to push changes to the fork and create a pull request. Authentication of the hub tool doesn't work. When I click on "push" in Repository Maintance I get an error. Somewhere in the stack trace there is this error:
'github.com username: github.com password for (never stored): '
'Error forking repository: Unauthorized (HTTP 401)\nRequires authentication'
I strongly suspect that Python can't open ~/.config/hub. The file definitely exists. Maybe this has to to with how ~ is resolved by Python?
I've figured it out by myself:
The problem is that '~/.config/hub' is resolved to '/root/.config/hub' when Weblate calls the GitHub hub program. However, the user Weblate is running as is weblate, so it doesn't have access to the root's home directory.
I've fixed this by hardcoding '/home/weblate/.config/hub' as the location of the Hub's config file and by making sure the config file is created at this location.

Rstudio: Changing origin for git version control of project

I originally set up git in Rstudio while enrolled in the Data Scientist's Toolbox course at Coursera. Unfortunately, I did this in my phd project. The repository no longer exists on github. I am now attempting to write my thesis in rmarkdown using knitr and bookdown. I would like to use version control, both to learn proper git workflow and to have a structured back up of everything I have done in my thesis. However, I have been unable to change the version control repository in Rstudio.
I am unable to change this in the Tools > Version control > Project setup > Git/SVN menu. The Origin: textbox is unchangable.
I tried creating a new project using the old phd project's working directory. This also cloned the version control settings.
How do I change the origin to accomplish what is described above?
Git, Github and Rstudio are different things. You could use git as local version control tools. You might connect your local repo to Github account which is based on git by push/pull. Rstudio just makes a user interface for git and supplies the function to push the repo into remote server based on git to make version control(not only Github, but also Gitlab).
So for your issue, if you do not want to pay for github for a private repo, all of your code would be public and I don't think it is good before your finally finished your thesis. But version control could be made locally with git only. Just use git shell to control the version.
However, as a student, github could support private repo here for you. Just register and find your student package. Then just remove the url for remote repo after you cd to your workdir in command line, use the following code to find your remote url(mostly you might fing origin):
git remote -v
Then use this to remove them:
git remote rm origin
Now you could use version control locally. If you want to connect this repo to your remote github private repo, use this:
git remote add origin https://github.com/[YourUsername]/[YourRepoName].git
RStudio would find this information about git and support your following operation. Project in RStudio is different with git, although project support git as version control tool. So you need git in command line or shell to solve your problem.
This can be done by opening /your.project/.git/config
and editing the remote origin line(s), e.g. changing from git to https.
Restart Rstudio & you'll be prompted for your github username & password.
This is what worked for me for migrating from github to Azure
Go to the top right Git window in RStudio and click on the gear. Now click Shell (to open the terminal there).
#remove origin
git remote rm origin
#add new origin like Azure for me via HTTPS
git remote add origin https://USER#dev.azure.com/USER/PROJECT/_git/REPONAME
#push your local repro
git push -u origin --all
#in my case put in the PAT password if you needed to generate one.
After testing, I found some clue
Actually Rstudio is not really smart about this setting
It will first search for the git file in the Rproject folder where your Rporject file is located
if it could not, then it goes up to the folder contains your Rproject folder
However, for version control you only need coding files while RProject may contains some big files like .RData some pictures etc.
I don't find a way to manually disrupt this logic flow, the only thing you can do is to delete the current git repository setting files(which is .git folder and 2 other git setting files), then Rstudio may ask you if you want to init a new one.

Unable to integrate Github with Pycharm

I have created a repository on Github. I am using Windows 7 64 bit and Pycharm Community edition. I want to integrate the Github repository with pycharm but I am getting the error
Couldn't get the list of GitHub repositories
Connect to api.github.com:443 [api.github.com/192.30.252.127] failed: connect timed out
Although I am able to clone he same repository from command prompt using git clone command.
I had the same issue.
Configure your proxy if using one:
File->Settings->System Settings->HTTP Proxy
Another thing to try is to clone the project locally then add as new project in Pycharm. Afterwards I was able to do all git operations under VCS->git including add/commit/push for my project.
try to check whether you have given the path to Git executable correctly by testing it using test button next to it...(file>settings>version control>Git>path to Git Executable)
make sure you have given the git client path correctly..
C:\Program Files\Git\cmd\git.exe

Work with GIT on remote site instead of local

I have to work on a project that is on a remote GIT repository. I have a development environment accessible via ssh: I would use git on it, but I like Eclipse EGit package so I would know if there's a way to connect my Eclipse with the remote cloned repository.
Depending on the network, you might be able to mount the remote filesystem locally and use Eclipse to access the code. This will not be great on slow network.
Alternatively you can tar up the source and just copy it locally, then periodically copy to the server.
If you say that you have the development environment accessible via ssh then how will eclipse help you if it isn't in a development environment? Wouldn't you need to recreate your development environment locally as well?
You can install a remote desktop solution like NoMachine and run eclipse on the remote machine.
Please provide more details.

Can't import bare git project into eclipse via ssh

I have recently set up a web server to which a user has ssh access. I created a new git repository on the server by doing the following:
user#server/dev:~$ git init --bare project.git
I am trying to import the project into my local eclipse instance, connecting using ssh. I have entered the following options:
ssh://user#host.com:1234/dev/project.git
Using the valid username and password in the options for "user". However, when I try to connect it fails to do so, but if I try and ssh to that directory as the same user via command line then I am able to get there.
What do I need to do to get the git project working correctly?
Found the problem. You have to use the absolute pathname rather than a user's relative one.
ssh://user#host.com:1234/home/user/dev/project.git