前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >Git 常用命令

Git 常用命令

作者头像
叙帝利
发布2018-10-15 15:13:00
4020
发布2018-10-15 15:13:00
举报
文章被收录于专栏:前端新视界

基本

Add

代码语言:javascript
复制
git add [--verbose | -v]
        [--dry-run | -n] 
        [--force | -f] 
        [--interactive | -i] 
        [--patch | -p]
        [--edit | -e] 
        [--[no-]all | --[no-]ignore-removal | [--update | -u]]
        [--intent-to-add | -N] 
        [--refresh] 
        [--ignore-errors] 
        [--ignore-missing] 
        [--renormalize]
        [--chmod=(+|-)x] 
        [--] 
        [<pathspec>…​]
代码语言:javascript
复制
# 添加所有文件
git add .

commit

代码语言:javascript
复制
git commit [-a | --interactive | --patch] 
           [-s] 
           [-v] 
           [-u<mode>] 
           [--amend]
           [--dry-run] 
           [(-c | -C | --fixup | --squash) <commit>]
           [-F <file> | -m <msg>] 
           [--reset-author] 
           [--allow-empty]
           [--allow-empty-message]
           [--no-verify] 
           [-e] 
           [--author=<author>]
           [--date=<date>]
           [--cleanup=<mode>] 
           [--[no-]status]
           [-i | -o] 
           [-S[<keyid>]] 
           [--] 
           [<file>…​]           
代码语言:javascript
复制
# 提交修改记录
git commit -m <msg>

reset

代码语言:javascript
复制
git reset [-q] 
          [<tree-ish>] 
          [--] 
          <paths>…​

git reset (--patch | -p) [<tree-ish>]  [--] [<paths>…​]
git reset [--soft | --mixed [-N] | --hard | --merge | --keep] [-q] [<commit>]
代码语言:javascript
复制
# 回滚到某个 commit
git reset --hard [<commit>]

分支与合并

branch

代码语言:javascript
复制
git branch [--color[=<when>] | --no-color] 
           [-r | -a]
           [--list] 
           [-v [--abbrev=<length> | --no-abbrev]]
           [--column[=<options>] | --no-column] 
           [--sort=<key>]
           [(--merged | --no-merged) [<commit>]]
           [--contains [<commit]] 
           [--no-contains [<commit>]]
           [--points-at <object>] 
           [--format=<format>]
           [<pattern>…​]
git branch [--track | --no-track] [-l] [-f] <branchname> [<start-point>]
git branch (--set-upstream-to=<upstream> | -u <upstream>) [<branchname>]
git branch --unset-upstream [<branchname>]
git branch (-m | -M) [<oldbranch>] <newbranch>
git branch (-c | -C) [<oldbranch>] <newbranch>
git branch (-d | -D) [-r] <branchname>…​
git branch --edit-description [<branchname>]
代码语言:javascript
复制
# 新建分支
git branch <branchname>
# 删除本地分支
git branch -d <branchname>
# 查看本地分支
git branch
# 查看所有(本地+远程)分支
git branch -a

checkout

代码语言:javascript
复制
git checkout [-q] [-f] [-m] [<branch>]
git checkout [-q] [-f] [-m] --detach [<branch>]
git checkout [-q] [-f] [-m] [--detach] <commit>
git checkout [-q] [-f] [-m] [[-b|-B|--orphan] <new_branch>] [<start_point>]
git checkout [-f|--ours|--theirs|-m|--conflict=<style>] [<tree-ish>] [--] <paths>…​
git checkout [<tree-ish>] [--] <pathspec>…​
git checkout (-p|--patch) [<tree-ish>] [--] [<paths>…​]
代码语言:javascript
复制
# 创建+切换分支
git checkout -b <branchname>

merge

代码语言:javascript
复制
git merge [-n] 
          [--stat] 
          [--no-commit] 
          [--squash] 
          [--[no-]edit]
          [-s <strategy>] 
          [-X <strategy-option>] 
          [-S[<keyid>]]
          [--[no-]allow-unrelated-histories]
          [--[no-]rerere-autoupdate] 
          [-m <msg>] 
          [-F <file>] 
          [<commit>…​]
git merge --abort
git merge --continue

分享及更新项目

fetch

代码语言:javascript
复制
git fetch [<options>] [<repository> [<refspec>…​]]
git fetch [<options>] <group>
git fetch --multiple [<options>] [(<repository> | <group>)…​]
git fetch --all [<options>]

push

代码语言:javascript
复制
git push [--all | --mirror | --tags] 
         [--follow-tags] 
         [--atomic] 
         [-n | --dry-run] 
         [--receive-pack=<git-receive-pack>]
         [--repo=<repository>] 
         [-f | --force] 
         [-d | --delete] 
         [--prune] 
         [-v | --verbose]
         [-u | --set-upstream] 
         [-o <string> | --push-option=<string>]
         [--[no-]signed|--signed=(true|false|if-asked)]
         [--force-with-lease[=<refname>[:<expect>]]]
         [--no-verify] 
         [<repository> [<refspec>…​]]
本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
原始发表:2018-10-13 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • 基本
    • Add
      • commit
        • reset
        • 分支与合并
          • branch
          • checkout
          • merge
          • 分享及更新项目
            • fetch
              • push
              领券
              问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档