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 2020
Lecture 7: Teamwork
Slides: https://hackmd.io/@hpc2n-git-2020/L7-teamwork#/
Teamwork
Concepts and commands
In these exercises we will use only a few commands. These have all been mentioned before in this course, but as a refresher I will briefly discuss a couple commands here, namely:
git fetch
: This is a primary command used to download contents from a remote repository.git push
: This is essentially the same as runninggit merge master
from inside the remote repository. It is mostly used to upload local changes to a remote repository.git pull
: This will fetch the latest changes from the current branch from a remote, then apply the changes to your local copy of the branch. It is similar to doing a fetch and a merge.Git push
or in some cases just
where the default behaviour is pushing to repository "origin" and the same branch as the local.
Before pushing:
After pushing:
Pushing a staged and committed file:
Git pull
Fetch the given remote's copy of the current branch and merge to the local copy:
or often just
If you have forgotten to pull before staging and committing new stuff, and your colleague has added something to the remote repository this is handy:
It fetches the remote content but does not create a new merge commit.
Assume this situation:
Now we do a
git pull
:Let us do an example where there is a new file on the remote repository:
First exercise - clone, push, pull
git clone
. Use the HTTPS address (click CODE to find it). See example:git add
,git commit
,git push
)git pull
before you stage and commit your file and use different names for your files. See the changes appear aftergit pull
git pull --rebase
before you dogit push
Second exercise, SSH keys
It is easier to use SSH keys than to enter username and password every time. In this exercise you create SSH keys and upload to GitHub. Then test that it works.
Create a new SSH key
.ssh
folder, open the fileid_rsa.pub
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
We now have SSH keys set up. Try and repeat some of the things that was done in the first exercise:
git pull
and see that you no longer have to enter your GitHub username and password, but you do have to enter the key passphrase.ssh-add
to add the key. Then you will only be asked for the passphrase once per session. This is relatively safe on Linux and macOS, but not on Windows where it usually saves the key passphrase permanently.Third exercise, branches and merging
git branch yourbranchname
where you put any name you want for the new branch.git push origin -u yourbranchname
git pull
git status
,git branch
, andgit log
to see what has happened.Third exercise, branches and merging - continued
git pull
git status
,git branch
, andgit log
to see what has happened.It is possible to make the master branch "protected" so it is not changed without a review from the owner.