For this workshop, you will need:
Please make sure to follow the instructions below to install and configure Git before the workshop.
Bash is a commonly-used shell that gives you the power to do tasks more quickly.
cmd
and press
Enter)Type the following line into the command prompt window exactly as shown:
setx HOME "%USERPROFILE%"
SUCCESS: Specified value was saved.
exit
then pressing EnterThis will provide you with both Git and Bash in the Git Bash program.
You can also follow this video tutorial
/Applications/Utilities
).See the Git installation video tutorial for an example on how to open the Terminal. You may want to keep Terminal in your dock for this workshop.
To see if your default shell is Bash type echo $SHELL
in Terminal and
press the Return key. If the message printed does not end with ‘/bash’
then your default is something else and you can run Bash by typing
bash
If you want to change your default shell, see this Apple Support article and follow the instructions on “How to change your default shell”.
The default shell is usually Bash and there is usually no need to install anything.
To see if your default shell is Bash type echo $SHELL
in a terminal
and press the Enter key. If the message printed does not end with
‘/bash’ then your default is something else and you can run Bash by
typing bash
.
Git is a version control system that lets you track who made changes to what when and has options for easily updating a shared or public version of your code on github.com, gitlab.com or bitbucket.org.
For macOS, install Git for Mac by downloading and running the most
recent “mavericks” installer from this
list. Because
this installer is not signed by the developer, you may have to right
click (control click) on the .pkg file, click Open, and click Open on
the pop up window. After installing Git, there will not be anything in
your /Applications
folder, as Git is a command line program. For
older versions of OS X (10.5-10.8) use the most recent available
installer labelled “snow-leopard” available
here.
You can also follow the following Video Tutorial
Please also verify your installation and configure Git.
If Git is not already available on your machine you can try to install it via your distribution package manager.
For Debian/Ubuntu run:
$ sudo apt-get install git
Check the version after installing:
$ git --version
For Fedora:
$ sudo dnf install git
Please also verify your installation and configure Git.
First, the following commands will set your user name and email address:
$ git config --global user.name "Your Name"
$ git config --global user.email username@gfz-potsdam.de
This is important since your Git commits use this information.
The --global
option ensures that you do not need to enter this information again on your machine.
It is important to set also the default text editor to use with Git. You can replace nano with vim, emacs or any other editor of your choice:
$ git config --global core.editor nano
If you use Atom as editor, set:
$ git config --global core.editor "atom -nw"
If you are on Windows and want to use Notepad or Notepad++, you can configure this by providing the full path to the executable and optionally set some options. For example (adjust the path if needed, and note the quotation):
$ git config --global core.editor "'C:/Program Files/Notepad++/notepad++.exe' -multiInst -notabbar -nosession -noPlugin"
To see where this information is stored (--show-origin
works on git version 2.8.0 or greater only), use:
$ git config --list --show-origin
You can also choose a different text editor of your choice, following this table:
Editor | Configuration command |
---|---|
Atom | $ git config --global core.editor "atom --wait" |
nano | $ git config --global core.editor "nano -w" |
BBEdit (Mac, with command line tools) | $ git config --global core.editor "bbedit -w" |
Sublime Text (Mac) | $ git config --global core.editor "/Applications/Sublime\ Text.app/Contents/SharedSupport/bin/subl -n -w" |
Sublime Text (Win, 32-bit install) | $ git config --global core.editor "'c:/program files (x86)/sublime text 3/sublime_text.exe' -w" |
Sublime Text (Win, 64-bit install) | $ git config --global core.editor "'c:/program files/sublime text 3/sublime_text.exe' -w" |
Notepad++ (Win, 32-bit install) | $ git config --global core.editor "'c:/program files (x86)/Notepad++/notepad++.exe' -multiInst -notabbar -nosession -noPlugin" |
Notepad++ (Win, 64-bit install) | $ git config --global core.editor "'c:/program files/Notepad++/notepad++.exe' -multiInst -notabbar -nosession -noPlugin" |
Kate (Linux) | $ git config --global core.editor "kate" |
Gedit (Linux) | $ git config --global core.editor "gedit --wait --new-window" |
Scratch (Linux) | $ git config --global core.editor "scratch-text-editor" |
Emacs | $ git config --global core.editor "emacs" |
Vim | $ git config --global core.editor "vim" |
VS Code | $ git config --global core.editor "code --wait" |
It is possible to reconfigure the text editor for Git whenever you want to change it.
Create a new example folder, step into it, then create a file example.txt
:
Initialize a repository and stage the new file:
$ git init
$ git add example.txt
$ git commit example.txt
$ git log
If you see now something line this (different name, email, and commit message), your Git is configured for the workshop:
$ git log
commit commitId (HEAD -> master)
Author: Author info (name and email address)
Date: time and tade of the commit
making a test commit
Visual diff tools allow to visualize differences between files side by side. They can be used independently of version control but when coupled with Git, they can provide a nice alternative to command line output to show differences between file versions or branches.
If you can’t get the visual diff tools to work, it’s OK: it’s only a demonstration in one exercise, and you won’t be prevented from doing anything else.
On Linux we recommend the program meld. Install meld via your distribution package manager. For Debian/Ubuntu run:
$ sudo apt-get install meld
For Fedora:
$ sudo dnf install meld
This is how you can configure Git to open Meld when doing git difftool
:
$ git config --global diff.tool meld
Please also verify your installation.
For macOS we recommend to use Opendiff. You can install it following this blog post. Please also verify your installation.
On Linux we recommend the program meld. Please follow installation instructions from http://meldmerge.org.
This is how you can configure Git to open Meld when doing git difftool
:
$ git config --global diff.tool meld
$ git config --global mergetool.meld.path "C:\Program Files (x86)\Meld\Meld.exe"
To test it create two text files which are similar and then compare them with Meld or Diffuse or Opendiff (or the tool which you have chosen above for visual differences):
$ meld file1 file2
or:
$ diffuse file1 file2
or:
$ opendiff file1 file2
You should now see both versions side by side.
To test launching Meld through Git, move into a folder that contains two or more files and instruct Git to compare files.
For example, to see the difference between file1.txt
and file2.txt
:
$ git difftool --no-index file1.txt file2.txt
Using the SSH protocol, you can connect and authenticate to remote servers and services. With SSH keys, you can connect to GitLab without supplying your username or password at each visit. You can follow this link to set it up
If you are unsure about this, you can skip this part and authenticate with GitLab using your username and password every time you will push changes to GitLab.