git 命令汇总

git 命令汇总

git 命令汇总

常用总结

1. $ git help  查看git所有命令的帮助

2.$ git config --global user.name manager

   $ git config --global user.email manager@gmail.com

* 以上两个命令会将用户信息保存在用户目录下的 .gitconfig 文件中

3.$ git config -l  查看当前所有配置

4.$ git status 查看当前代码库状态

5.$ git add .  将当前文件夹下的所有新建或修改的文件一次性添加到代码库

6.$ git commit -m "添加了main.c"   将修改提交到代码库

提示:*   在此一定要使用 -m 参数指定修改的备注信息

7.$ git log  查看所有版本库日志

    $ git reflog  查看分支引用记录

8.$ git reset --hard HEAD  回到当前版本,放弃所有没有提交的修改

    $ git reset --hard HEAD^  回到上一个版本

    $ git reset --hard HEAD~3 回到之前第3个修订版本

    $ git reset --hard e695b67  回到指定版本号的版本

9.$git diff  查看文件变化

10.$git checkout文件名  撤销对文件做的修改

11.$git echo '文件名' >.gitignore  忽略文件

12.$git rm文件名  删除文件

13.$git branch -r  查看远程分支

14.$git branch -r -d  删除远程分支

15.git merge  来源分支名  在目的分支上合并来源分支(先切到目的分支上)

附$git --help:

usage: git[--version][--help][-C ][-c name=value][--exec-path[=]][--html-path][--man-path][--info-path]

           [-p | --paginate | --no-pager][--no-replace-objects][--bare]  [--git-dir=][--work-tree=][--namespace=][]

These are common Git commands used in various situations:

start a working area(see also: git help tutorial)

   clone      Clone a repository into a new directory

   init      Create an empty Git repository or reinitialize an existing one work on the current change(see also: git help everyday)

   add        Add file contents to the index

   mv        Move or rename a file,a directory,or a symlink

   reset      Reset current HEAD to the specified state

   rm        Remove files from the working tree and from the index examine the history and state(see also: git help revisions)

   bisect    Use binary search to find the commit that introduced a bug

   grep      Print lines matching a pattern

   log        Show commit logs

   show      Show various types of objects

   status    Show the working tree status grow,mark and tweak your common history

   branch    List,create,or delete branches

   checkout  Switch branches or restore working tree files

   commit    Record changes to the repository

   diff      Show changes between commits,commit and working tree,etc

   merge      Join two or more development histories together

   rebase    Reapply commits on top of another base tip

   tag        Create,list,delete or verify a tag object signed with GPG collaborate(see also: git help workflows)

   fetch      Download objects and refs from another repository

   pull      Fetch from and integrate with another repository or a local branch

   push      Update remote refs along with associated objects

'git help -a' and 'git help -g' list available subcommands and some

concept guides. See 'git help <command>' or 'git help <concept>'

to read about a specific subcommand or concept.

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容