zoukankan      html  css  js  c++  java
  • git 基础命令

    Create a repository

    method 1:

    create a new local repository

    git init  (project name)

    method 2:

    download fron an existing repository

    git clone my_url

    Observer your repository

    List new or modified files not yet committed

    git status

    Show the changes to file not yet staged

    git diff

    Show the changes to staged files

    git diff --cached

    Show all staged and unstaged

    git diff HEAD

    Show the changed between two commit ids

    git diff commit1 commit2

    List the change dates and authors for a file

    git blame [file]

    Show the file changes for a commit id and /or file

    git show [commit]:[file]

    Show full change history

    git log

    Show change historyy for file/directory including diffs

    git log -p [file/directory]

    Working with Branches

    List all local branches

    git branch

    List all branches, local and remote

    git branch -av

    Switch to a branch, my_branch. and update working directory

    git checkout my_branch

    Create a new branch alled new_branch

    git branch new_branch

    Delete the branch called my_branch

    git branch -d my_branch

    Merge branch_a into branch_b

    git checkout branch_b

    git merge branch_a

    Tag the current commit

    git tag my_tag

    Make a change

    Stages the file, ready for commit

    git add [file]

    Stage all changed files, ready for commit

    git add .

    Commit all staged files to versioned history

    git commit -m "commit mesage"

    Commit all your tracked files to versioned history

    git commit -am "commit message"

    Unstages file, keeping the file channges

    git reset [file]

    Revert everything to the last commit

    git reset --hard

    Synchronize

    Get the latest changes from origin(no merge)

    git fetch

    Fetch the latest changes from origin and merge

    git pull

    Fetch the latest changes from origin and rebase

    git pull --rebase

    push local changes to the origin 

    git push

    Finally

    When in doubt, use git help

    git command --help

    or visit https://training.github.com/

  • 相关阅读:
    二级菜单
    eclipse高版本中EasyExplore的替换插件OpenExplore
    Python学习一
    原型编程的基本规则
    【CF671D】 Roads in Yusland(对偶问题,左偏树)
    【洛谷4542】 [ZJOI2011]营救皮卡丘(最小费用最大流)
    【洛谷4313】 文理分科(最小割)
    【洛谷4001】 [ICPC-Beijing 2006]狼抓兔子(最小割)
    【洛谷2057】 [SHOI2007]善意的投票(最小割)
    【洛谷2053】 [SCOI2007]修车(费用流)
  • 原文地址:https://www.cnblogs.com/coxiseed/p/11940131.html
Copyright © 2011-2022 走看看