Git 指令收集

git命令介绍 git

  • git简单命令
    web

  • git init该命令用来安装Git追溯项目更改历史的全部工具。 工具

    git add filename fetch

    git status this

    git log
    spa

    git commit -m "comments" code

    git checkout HEAD filename: Discards changes in the working directory. (从repositorycheckout覆盖当前工做目录的内容) orm

    git reset HEAD filename: Unstages file changes in the staging area.(reset 'git add '以后的内容) 开发

    git reset SHA: Can be used to reset to a previous commit in your commit history.(reset到上一次commit, SHA表示SHA码的前7位) rem


  • git branch介绍

  •         git默认只在masterbranch工做,若是想要在其余的版本上作些实验性的功能开发能够用到多个branch.

    git branch: 显示全部的branch, 最初只有 master

    建立一个新的branch : git branch new_branch

    刚建立出来的新branch 跟master是同样的,他们是共享一样的commit历史。能够用以下命令切换branch:

    git checkout new_branch

     将两个branch 的commit代码合并:

    git merge branch_name

     例如将new_branch的代码merge到master的步骤:

            1. 切换到master : git checkout master

            2. merge branch: git merge new_branch

    branch任务开发完成merge到mater以后就能够关闭new_branch了

    git branch -d new_branch


  • git团队协做

  • clone远程的repository:

    git clone remote_location clone_name  

    在这个命令中:

    remote_location 告诉 Git 去找找到 remote. 它能够是一个web地址,或者是一个文件路径:/Users/teachers/Documents/some-remote

    clone_name 是指定Git clone repository放置的路径名

    The workflow for Git collaborations typically follows this order:

    1.Fetch and merge changes from the remote (git clone ; git merge)

    2.Create a branch to work on a new project feature (git branch)

    3.Develop the feature on your branch and commit your work

    4.Fetch and merge from the remote again (in case new commits were made while you were working) (git fetch; git merge)

    5.Push your branch up to the remote for review (git push)


    git clone: Creates a local copy of a remote.

    git remote -v: Lists a Git project's remotes.

    git fetch: Fetches work from the remote into the local copy.

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

    git push origin <branch_name>: Pushes a local branch to the originremote.

相关文章
相关标签/搜索