or
or
By clicking below, you agree to our terms of service.
New to HackMD? Sign up
Syntax | Example | Reference | |
---|---|---|---|
# Header | Header | 基本排版 | |
- Unordered List |
|
||
1. Ordered List |
|
||
- [ ] Todo List |
|
||
> Blockquote | Blockquote |
||
**Bold font** | Bold font | ||
*Italics font* | Italics font | ||
~~Strikethrough~~ | |||
19^th^ | 19th | ||
H~2~O | H2O | ||
++Inserted text++ | Inserted text | ||
==Marked text== | Marked text | ||
[link text](https:// "title") | Link | ||
 | Image | ||
`Code` | Code |
在筆記中貼入程式碼 | |
```javascript var i = 0; ``` |
|
||
:smile: | ![]() |
Emoji list | |
{%youtube youtube_id %} | Externals | ||
$L^aT_eX$ | LaTeX | ||
:::info This is a alert area. ::: |
This is a alert area. |
On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?
Please give us some advice and help us improve HackMD.
Do you want to remove this version name and description?
Syncing
xxxxxxxxxx
Introduction to Git –- Fall 2024
Lecture 0: Setup
Slides: https://hackmd.io/@git-fall-2024/L0-setup
Installing and setting up Git
We will use Git from the command line in this course. This is normally how you will use it on the various HPC centers, and this way it will also be easier to understand what is going on while you are learning to use Git. On Windows, this means you will be using Git Bash.
Graphical tools exists for Git, see below list for a few. All entries on the list are free and unless otherwise mentioned, available for Windows, macOS, and Linux:
Installing and setting up Git - continued
git init
git config
(local, global, system). More info in a moment.git add
git commit
git log
that all looks well.When this is done, you will clone the course materials.
Installing and setting up Git - continued
NOTE: if you have a problem getting this to work on your own computer, and you have an account at Tetralith or any other HPC system, then you can use that instead.
We have some documentation for you for Tetralith:
https://hackmd.io/@git-fall-2024/tetralith.
As mentioned, you may also use any other HPC system you have an account at, of course. The above documentation would need only minor adjustements.
Git install - Windows
Git install - macOS
If you have installed XCode (or its Command Line Tools), Git may already be installed. To find out, open a terminal and enter
git --version
.If Git is not installed, you have several installation options. Apple maintains their own fork of Git, but it is usually a few versions behind, so we do not recommend installing that.
brew install git
Git install - Linux
Git is usually already installed on Linux, but if not, this is how you install it.
Installing Git on Linux depends on which distro you are running.
sudo apt-get install git
(Ubuntu, Debian)sudo dnf install git
(RHEL, CentOS)Git install - primary branch
Configure git (all OS)
First check that you have git installed (in a terminal or in Git Bash):
Now configure git with
git config (local, global, system)
You should at least set your global name and email (just once):
Configure git (all OS) - continued
Setting the editor (once) is also a good idea:
Choices for editor could be (on Linux, though can be installed together with Git for other OS):
You should be able to use notepad on Windows by setting:
git config --global core.editor "<path-to>/notepad++.exe"
Another option could be to install VS Code and do this config instead:
git config --global core.editor "code --wait"
GitHub has some documentation on choosing and setting editors for various OS:
https://docs.github.com/en/get-started/getting-started-with-git/associating-text-editors-with-git
See more about configuring and using editors with Git at the end of this document.
Test your Git installation
Create an example folder and change to that, then create a file test.txt. On Linux you would do this:
Now initialize a repository and stage the new file:
Now commit the change. The editor which you configured earlier should open. Add an example commit message:
Test your Git installation - continued
Now let us look at the log:
When you do
git log
, you should see something like the above, but with name, email, date, and commit message different. If that is the case, your Git should be configured correctly.Download the course materials
For the individual hands-on part of the course, we have created some course materials which you will download from the course GitHub: https://github.com/hpc2n/course-intro-git (normally you click the green "Code" button to get the link to clone or download)
git clone https://github.com/hpc2n/course-intro-git.git
wget https://github.com/hpc2n/course-intro-git/archive/refs/heads/main.zip
or elsewhere then transfer) and unzip. You can also get the link from the course GitHub: https://github.com/hpc2n/course-intro-git.Web based Git repositories
There are several web based Git repositories. Some of the more popular ones are:
We are going to use GitHub for the part of the hands-on where you will be working together in groups.
Please go to
and sign up for an account. You will need to setup 2FA also.
Create a new SSH key for GitHub - Linux and macOS
This part will be done before the section "Working with remotes" on day 4, but you can create and add your SSH key to GitHub now if you want to.
a. Do this
Create a new SSH key for GitHub - Linux and macOS
.ssh/id_rsa
for the legacy system):.ssh
folder, open the fileid_ed25519.pub
with some editor and copy it (id_rsa
for legacy systems). Do NOT add any newlines or whitespace!Create a new SSH key for GitHub - Windows
This part will be done during the exercises on day 5, but you can create and add your SSH key to GitHub now if you want to.
a. Do this
Create a new SSH key for GitHub - Windows
.ssh/id_rsa
for the legacy system):.ssh
folder, with some editor, open the fileid_ed25519.pub
(orid_rsa.pub
for the legacy systems) and copy it. Do NOT add any newlines or whitespace!Adding the SSH key to GitHub
Testing the SSH keys
$ ssh -T git@github.com
More on editors, Linux
Vim
sudo apt-get install vim
)vim <filename>
to open a file for editing. The file will be created if it does not exist before.i
to enter 'insert' mode to be able to write in the editor.ESC
to go to 'command' mode and then:wq
to save and exit the editor.:q!
while in 'command mode'.dd
will delete the whole line your cursor is on.Nano
sudo apt-get install nano
)nano <filename>
to open a file for editing. The file will be created if it does not exist before.nano
and did not give a filename, it will ask you for a name.More on editors, Windows
git config --global core.editor notepad
git config --global core.editor "<path-to>\notepad++.exe"
git config --global core-editor "C:\Program Files (x86)\Notepad++\notepad++.exe"
git config --global core.editor vim
GitHub has a page for setting some editors for various OS'es: https://docs.github.com/en/get-started/getting-started-with-git/associating-text-editors-with-git
More on editors, various OS
GitHub has a page for setting some editors for various OS'es:
https://docs.github.com/en/get-started/getting-started-with-git/associating-text-editors-with-git
GitHub CLI
GitHub also has a command line interface that you can use if you want to.
It is available for Windows, macOS, and Linux.
You can use it if you prefer to do your workflow through a terminal, and you can call the GitHub API to script various actions as well as set a custom alias for any command.
More information and download here: