Using Git

From LUG
Revision as of 14:35, 1 March 2017 by Dawes001 (talk | contribs) (Created page with "Git is a popular open source version and source code management tool. At Wageningen U&R, we have our own repository management service at https://git.wageningenur.nl , a gitla...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Git is a popular open source version and source code management tool. At Wageningen U&R, we have our own repository management service at https://git.wageningenur.nl , a gitlab instance.

There are several other good introductions on how to use Git for common use (such as here ), but here I will aim to give you the basics for use at Wageningen.

Because of the way Gitlab works, in order to do anything you must first log in once, using your email. This will create an internal user within Gitlab, allowing you to create, browse, and edit projects. If you are trying to collaborate with someone who has not done this step, you will find that you cannot search for their user, as Gitlab doesn't believe it exists.

Next, once you have an account, the next thing you need to do is to add a public key to it. This requires a basic understanding of Using_SSH - if you don't, go there to get acquainted. Go to https://git.wageningenur.nl/profile and then select 'SSH Keys'. If you paste a key with a comment into the Key section, the Title field ought to be automatically completed as this, otherwise you'll have to fill in something unique. Click 'Add Key' and you're done.

Now you can create a new repo. Go back to the start page and hit 'New Project'. The important field is 'Project Name' - this must be unique to your group, and contain no spaces. The Visibility Level is important if you aim to share your code - by default it's private, but you can set it to public. If you create a group (later), all private repos are shared by all members of the group, so you can more carefully control access this way. Hit 'Create Project'.

Git is capable of working in two modes - local, and remote. You can initialise a local repo and only keep it local, tracking only changes locally, or you can elect to push these up to Gitlab. The instructions given to you as you create a new project cover both existing and new local repos. For completeness sake, I've included them here:


Git global setup

git config --global user.name "Dawes, Gwen" git config --global user.email "gwen.dawes@wur.nl"

Create a new repository

git clone git@git.wur.nl:dawes001/test-project.git cd test-project touch README.md git add README.md git commit -m "add README" git push -u origin master

Existing folder

cd existing_folder git init git remote add origin git@git.wur.nl:dawes001/test-project.git git add . git commit git push -u origin master

Existing Git repository

cd existing_repo git remote add origin git@git.wur.nl:dawes001/test-project.git git push -u origin --all git push -u origin --tags