美文网首页
Learning Git

Learning Git

作者: 咸鱼干lili | 来源:发表于2018-04-12 20:15 被阅读0次

    周末终于把Git学了,目的是更好的理解和使用Github。附上操作命令的学习笔记~

    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 (重点)

    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


    笔记来源于Codecademy网站。

    相关文章

      网友评论

          本文标题:Learning Git

          本文链接:https://www.haomeiwen.com/subject/kxifkftx.html