Learning Git

周末終于把Git學(xué)了,目的是更好的理解和使用Github。附上操作命令的學(xué)習(xí)筆記~

Chap-1 Git workflow

image

Git commands - to help keep track of changes make to a project:

  1. git init : create a new Git repository

  2. git status: inspect the contents of the working directory and staging area

  3. git add: adds files from the woking directory to the staging area

  4. git diff: shows the difference between the working directory and the staging area

  5. git commit: permanently store file changes form the staging area in the repository ( e.g.: git commit -m “add a line ” )

Chap-2 Backtrack in Git

  1. git checkout HEAD filename: Discards changes in the working directory

  2. git reset HEAD filename: Unstage file changes in the staging area

  3. git reset commit_SHA: reset to a previous commit in your commit history

  4. git add filename_1 filename_2 : add multiple files to the staging area with a single command

Chap-3 Branch (重點(diǎn))

Git branching allows users to experiment with different versions of project by checking out separate branches to work on.

  1. git branch: lists all a Git project’s branches. ( 1) include: master / other branches; 2) * mark means where you are)

  2. git branch branch_name: creates a new branch

    image

    (The master and fencing branches are identical: they share the same exact commit history)

  3. git checkout branch_name: used to switch from one branch to another ( commands on this branch have no impact on master)

  4. git merge branch_name: used to join file changes from one branch to another (Fast-forward :The merge is a "fast forward" because Git recognizes that fencing contains the most recent commit. )

  5. git branch -d branch_name: Deletes the branch specified

Chap-4 Git Teamwork

A remote is a Git repository that lives outside your Git project folder.

  1. git clone: creates a local copy of a remote

  2. git remote -v: lists a Git project’s remotes

  3. git fetch: fetches work from the remote into the local copy

  4. git merge origin/master: Merges origin/master into your local branch

  5. git push origin branch_name: pushes a local branch to the origin remote


筆記來(lái)源于Codecademy網(wǎng)站。

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書(shū)系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容