Skip to content

Setting up a local Git repository

Marco Brandizi edited this page Jun 4, 2018 · 8 revisions

Setting up a local Git repository

There are several guides explaining how to make GitHub authentication working from a command line client. Here I'm going to explain what it worked for me after having read several documents and made several attempts. Authentication is needed to write on a GH repository (i.e., to push), and to access private repositories.

I'm going to talk about HTTPS-based access only since most of Rothamsted servers cannot do ssh outside our intranet.

What follows applies to the command line versions of git, visual clients (e.g., SmartGit, Eclipse e-git) might have their own way to store credentials, which don't need the hereby kind of setup.

Linux

Create .gitconfig in your home directory, having contents like this:

[credential]
	helper = store
[credential "https://github.com"]
	username = marco-brandizi
[push]
	default = current
[user]
	name = marco-brandizi
	email = [email protected]

(obviously, you need to change my details with yours).

Next, let's setup the credentials details. Use a web browser to go to GitHub -> Settings -> Developer settings -> Personal access tokens. Create a specific-enough token and give it a sensible name, e.g. I've created 'Rothamsted Servers'.

Do not reuse the same token for everything, that's a security weakness and having distinguished tokens allows you to detach your account from single projects when that's needed.

Don't grant your token unnecessary permissions. Usually, repo access, notifications access and user access are enough.

As a final step, copy-paste of the key GH shows you to the file .git-credentials in your home, using this format:

https://marco-brandizi:2b08e***@github.com

Now, git commands that require authentication should be working. You can start with operations like git clone https://github.com/Rothamsted/xxx

Note: It's known that git clients below 1.7.10 don't work with GH tokens. Update your git installation in case of problems.

Note: You should protect .git-credentials (chmod go-rwxs .git-credentials). The file accepts clear account-level passwords too (the one you use via web), in place of tokens. I guess there's no need to explain why tokens are safer.

Relevant Plug-Ins

RDF Exporter
Neo4j Exporter
New Tab/CSV Importer

Relevant Related External Tools

BK-Net Ontology
rdf2neo tool for RDF->Neo4j

Clone this wiki locally