2018 Program Design 2
CSIE 梁祐承
You can install by yourself
but remember to test your code
with VM image provided by TA
Select the host OS you're using
Adjust by your computer spec!
Use the image provided by TA
username & password are both 'pd2vm'
$ sudo apt install git
Pre-installed in VM provided by TA
If you already have linux installed...
If you're using windows...
Search from Google and choose the one you like
Basic unit in git.
In most case, you will call your project using git as repository.
Record you code change in git repository, you can view difference between commits.
Working space
Staging area
Local repo
add
commit
Remote repo
(Github/Gitlab)
push
pull/clone
$ git config --global user.email "your@email.com"
$ git config --global user.name "your_git_account"
$ git config --global core.editor "vim"
$ git config -l
user.email=your@email.com
user.name=your_git_account
core.editor=vim
$ git clone https://pd2b.imslab.org/gitlab/HMKRL/test.git
Cloning into 'test'...
Username for 'https://pd2b.imslab.org': <your username>
Password for 'https://hmkrl@pd2b.imslab.org': <your password>
remote: Counting objects: 35, done.
remote: Compressing objects: 100% (19/19), done.
remote: Total 35 (delta 10), reused 35 (delta 10)
Unpacking objects: 100% (35/35), done.
# Run command in your repo folder
$ git init
Initialized empty Git repository in /home/user/my_proj/.git/
# ... start to write your code
$ git status
On branch master
Your branch is up-to-date with 'origin/master'.
nothing to commit, working tree clean
$ vim hw1.c
$ git status
On branch master
Your branch is up-to-date with 'origin/master'.
Untracked files:
(use "git add <file>..." to include in what will be committed)
hw1.c
nothing added to commit but untracked files present (use "git add" to track)
$ git status
Untracked files:
(use "git add <file>..." to include in what will be committed)
hw1.c
nothing added to commit but untracked files present (use "git add" to track)
$ git add hw1.c
$ git status
Changes to be committed:
(use "git reset HEAD <file>..." to unstage)
new file: hw1.c
$ git status
Changes to be committed:
(use "git reset HEAD <file>..." to unstage)
new file: hw1.c
$ git commit
# Edit commit message in vim
[master 52c637e] commit example
1 file changed, 0 insertions(+), 0 deletions(-)
create mode 100644 hw1.c
$ git log
commit 52c637efecc9969cef9a8a753e59097143928b31
Author: Yu-Cheng Liang <a135246a135246@gmail.com>
Date: Sat Mar 10 00:11:53 2018 +0800
commit example
commit 613a350b0ddeaa4f586981404eae41704ef69c99
Author: You-Cheng Liang <liangyc39@gmail.com>
Date: Sat Feb 10 13:55:46 2018 +0800
sleep
# set default push repo
$ git push -u origin master
Username for 'https://pd2b.imslab.org': <your username>
Password for 'https://hmkrl@pd2b.imslab.org': <your password>
Counting objects: 3, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 271 bytes | 0 bytes/s, done.
Total 3 (delta 1), reused 0 (delta 0)
To https://pd2b.imslab.org/gitlab/HMKRL/test.git
613a350..52c637e master -> master
Branch master set up to track remote branch master from origin.
# Push directly
$ git push
$ git pull
Username for 'https://pd2b.imslab.org': <your username>
Password for 'https://hmkrl@pd2b.imslab.org': <your password>
remote: Counting objects: 2, done.
remote: Compressing objects: 100% (2/2), done.
remote: Total 2 (delta 1), reused 0 (delta 0)
Unpacking objects: 100% (2/2), done.
From https://pd2b.imslab.org/gitlab/HMKRL/test
52c637e..8f0b454 master -> origin/master
Updating 52c637e..8f0b454
Fast-forward
new_file | 0
1 file changed, 0 insertions(+), 0 deletions(-)
create mode 100644 new_file
Feel free to try if you're interested!
If password reset link expired or you forgot your password, click here and enter your <stuID>@mail.ncku.edu.tw
Copy your public key