Rayologist / github-demo

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Github Workflow Demonstration

Why do we want to use Git?

The following pictures are from: 連猴子都能懂的 Git 入門指南


Problem 1: Chaotic Namings and Versions of Files

Problem 1: Chaotic Namings and Versions of Files


Problem 2: Conflicts When Collaborating on the Same Files

Problem 2: Conflicts When Collaborating on the Same Files


Git: Preserving File Versions and Raising Warnings When Modifying the Same Files

Git: Preserving File Versions and Raising Warnings When Modifying the Same Files

What is Git?

Git is a distributed version control system


The following picture is from: Manisha Basra

1.

Distributed Version Control

Distributed Version Control System

Git vs. Github

From the Stackoverflow:

  1. Git is a revision (or version) control system, a tool to manage your source code history.

  2. GitHub is a hosting service for Git repositories.

  3. So they are not the same thing: Git is the tool, GitHub is the service for projects that use Git.


Git Commands vs. Github Desktop

Both are able to do the same things, but using commands will be a lot faster than using Github Desktop.


1. Basic Shell Commands

1. Print Working Directory

pwd

2. Change Directory

cd your/file/path/

3. Make Directroy

mkdir your/folder/name

4. Move or Rename Files

# move files
mv your/path/origin_name your/other/path/origin_name
# rename files
mv origin_name modified_name

5. List (files)

ls your/directory/

6. Read Files

# Print out all of your file contents
# cat: concatenate
cat <your file name>
cat <your first file name> <second> <etc>
# Print out your file contents one page at a time
less <your file name>

# press "q" to quit
# press "space bar" to output next page

7. Remove Files or Folders

Be careful using the following conmmands. Files or folders will be deleted permanently without being able to be recovered.

# Remove files
rm <your file path>
# Remove folders
rm -r <your folder>
# or
rmdir <your folder>

8. Clear Console

clear

2. Symbols

/ # root directory
~ # home directory
. # current directory
.. # parent directory

3. Github Setup (SSH)

1. Check if SSH public key exists

ls ~/.ssh

2. If not, type:

ssh-keygen

3. Copy your ssh key to Github

# For Mac
pbcopy < ~/.ssh/your.pub
# For Windows
clip < ~/.ssh/your.pub
  1. Click your profile picture and find Settings.

    settings

  2. Click SSH and GPG keys on the left hand side.

    ssh-gpg-keys

  3. Click New SSH Keys

    new-ssh-key

  4. Click Add SSH key after filling out the form

    add-ssh-keys

4. Using Git Verbs

1. Fork: make a copy from other's repository

Fork

2. Clone: download everything in a repository

git-clone

git clone <your copied url>

or you can rename the folder

git clone <your copied url> <folder name you want>

Remember to cd into the folder you clone

cd <folder name you want>

You can also combine the commands above as in the following example (the symbol && means and):

git clone git@github.com:NTU-Speech-Behavior-and-Science-Lab/github-demo.git github-demonstration && cd github-demonstration

3. Status: check Git status

git status

4. Log: check Git history

git log

5. Add: allow Git to track file changes

git add your-file-name
git add .

6. Commit: submit a new version to Git

git commit -m "your commit message"

7. Push: updating remote repository

git push

NEVER DO THIS Unless You Know What You Are Doing

# -f: force, will ignore any conflicts in the remote repository, wiping out your team members' hard work.

git push -f

8. Pull: updating local repository

git pull

5. Pull Request (PR)

1.

Pull-request

2.

New-Pull-Request-Button

3.

Create pull request

4.

Open pull request

6. Practice

Add your name and github account below.

7. Resources

W3HexShool

連猴子都能懂的 Git 入門指南

為你自己學 Git

About

License:Apache License 2.0