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
git
ECHO $(WHOAMI)
№Ball
太空三
Todays slide
Before that
What is git?
Advanced git
Let's assume that you have a program.
Called FinalProject
How do you often store your data?
How do you often store your data?
What if you are trying to cooperate with classmates?
Moreover
Do you even know the different between V4 and V1?
Moreover
What if someone changed and somehow the program just doesn't work where CRTL+Z doesn't help you?
What is git?
A version controller
How to git?
As a master said before
You only need to know the basics
Basic
STAGES
of gitBasic
STAGES
of gitWhat is a Repo?
Repository
which you can see as a project file (often a directory)Review
What is the stage that you write your codes?
Working Directory
Working Directory
Creating one
Result
Go ahead an play make changes
Quick Review
After finishing a period, what stage will you want to enter
Staging Area
OFTEN USED COMMAND
Results
branch
are you onStaging Area
OFTEN USED COMMAND
.
stands for everythingStaging Area
OFTEN USED COMMAND
Any differents?
Quick Review
After staging a file, what will you want to do?
Local Repos
Which is
commit
.This means to put all the thing from stage into your repo, and telling what have you done or why do you do this.
Before that
We need a GOOD convention of commit so that we know what you are writing
A COMMIT SHOULD
type
-> need to discuss before using, however it often contians and can be more of themFIX
ADD
FEAT
DOCS
TEST
A COMMIT SHOULD
scope
-> sometimes we don't need them, but when we are in a big project, it will give a better view of what the error isdescription
-> the reason you make this commitbody
-> further descriptions if neededfooter
-> ReferencesA COMMIT SHOULD NOT
BE NONSENSE
Trust me, you will find out that this is hard.
Let's try shell we?
OFTEN USED COMMAND
RESULT
Let's see if it works
OFTEN USED COMMAND
RESULT
What if we have a typo?
Go ahead and do something else to your file
Let's check status again
OFTEN USED COMMAND
RESULT
We just don't need that much descriptions
Now we know how to create files to repo
How to see the changes and what happens is the most important thing.
LOGS
git log
-> repo's historygit reflog
-> whole git historyGive it a try!
RESULT
Too long?
More Usage
RESULT
What if
What if
You will never ever put an unworkable program on master
Let's add pretend we are another user.
SAVIOR - branches
SAVIOR - branches
OFTEN USED COMMAND
jason
-> your branch namedev
-> short of developeALWAYS REMEMBER TO CHECK WHICH BRANCH YOU ARE ON
OFTEN USED COMMAND
SAVIOR - branches
List all the branches you have (LOCAL)
OFTEN USED COMMAND
RESULT
You can see that we have three branches.
SAVIOR - branches
Switch through branches
OFTEN USED COMMAND
jason
-> the target branch you want to switch toResult
Remember to check if it is successed by
status
Pretending someone
Make more changes!
Append words to NCU is important for future usage.
Don't forget to commit it!
Pretending someone
OFTEN USED COMMAND
Have U done it right?
Quick review
How to check your git movements?
REFLOG!
RESULT
Practice
dev
branch.master
branch.jason
branch.1.
once again.NOTE
If you are correct
graph
-> The graph viewall
-> not only the current branchWhat are these
network
Time to add (
merge
) them together!What is merge?
Making two branches together.
How to merge?
you have to be on
master
branch!OFTEN USED COMMAND
jason
-> your targeted branchNote
branch
jason
will not change, that's reasonable, since you can only modify what's on your current branch.If you are correct
Wow Looks real cool
Let's merge dev and see what happens!
With some prettfier
Try it yourself!
Merges are not always fluent
dev
branchNCU
jason
had append words toNCU
master
->NCU
had appended wordsdev
andmaster
have its own appended words -> git doesn't know which to use -> CONFLICTMERGE CONFLICTS
OFTEN USED COMMAND
RESULT
MERGE CONFLICTS
<<<<<< HEAD
-> current status>>>>>> dev
-> incomming changesYou should choose. Keep both, leave one, delete both… whatever you like!
I chose to keep dev
MERGE CONFLICTS
If everything works fine
GIT FLOW
How to git
IMPORTANT
You will never ever put an unworkable program on master.
WHO?
AUTHOR
-> the target file to askExpected result
-L a, b
can be used for linesOOPS
I don't like this
Quick Reviews
STAGES
of gitQuick Review
How to get to the wanted version?
I don't like
Working Directory
OFTEN USED COMMAND
add
,.
for everything or you can type the filename you want to restoreQUICK TEST
I don't like
Staging Area
add
,.
for everything or you can type the filename you want to restoreQUICK TEST
I don't like
REPO
OPTIONS
--soft
-> only changing status--hard
-> changes everything back to the commit statusgit reset --soft
+git checkout .
QUICK TEST SOFT
QUICK TEST HARD
I don't like
COMMIT
QUICK TEST
REMOTE
LET'S REMOTE
REGISTRATION
register a gitlab account!
GET REMOTE REPO
OFTEN USED COMMAND
git clone <repo url>
GITHUB
WHAT IS
Clone methods
Create a github
Lets create a repository
Go to Create a new repository
fill out the forms
You made it!