美文网首页
2018-08-09 Git命令使用问题和FAQ

2018-08-09 Git命令使用问题和FAQ

作者: 遵天循道 | 来源:发表于2018-08-09 10:05 被阅读29次

    Git FAQ

    有不懂的地方看此链接,文图视频教学👍:

    https://www.liaoxuefeng.com/wiki/0013739516305929606dd18361248578c67b8067c8c017b000

    一、常用命令:

    git clone  git address

    git pull origin master

    git status

    git add -A  提交所有变化

    git add -u  提交被修改(modified)和被删除(deleted)文件,不包括新文件(new)

    git add .  提交新文件(new)和被修改(modified)文件,不包括被删除(deleted)文件

    git commit -a -m "first commit"  == git commit -am "some str"

    git push -u origin master

    git push

    如何增加Git的命令缩写,你需要修改Git的.gitconfig文件,一般git的在默认路径:~/Users/jiaozhiyu(用户名)下面的隐藏目录(查看隐藏文件的快捷键:command+shift+.)。

    [alias]

    co = checkout

    ci = commit

    st = status

    pl = pull

    ps = push

    dt = difftool

    l = log --stat

    cp = cherry-pick

    ca = commit -a

    b = branch

    二、如何解决git冲突

    转载:https://blog.csdn.net/sureSand/article/details/78765727

    1git pull origin master

    2git status -uno查看一下状态

    1)、changes to be committed

    2)、unmerged paths

    3)、changes not staged for commit

    3、查看和解决冲突标记

    冲突标记:冲突标记<<<<<<< 与=======之间的内容是我的修改,=======与>>>>>>>之间的内容是别人的修改。 

    4、修改完标记冲突提交到Stage

    git add到暂存区(make code staged

    1)、git add files

    2)、git commit -m "your comment"

    5再用git status -uno查看文件状态 

    发现Unmerged path文件已经没有了,我们直接git push提交到远程仓库

    git push origin master

    Git的冲突解决和SVN雷同。

    三、为什么要先git add才能git commit?

    转载:http://www.360doc.com/content/18/0414/22/11935121_745698056.shtml

    git如何上传所有的新文件

    转载:https://blog.csdn.net/qq_28093585/article/details/78749153

    目的描述:新建的git项目,项目中有许多要从本地上传到git仓库的新文件,如果用git -a filename的方法一个一个的添加,太费事费力,需要有命令添加所有改动。

    步骤:进入项目文件夹,在其中使用git bash

    1.使用git clone命令将新建的git 项目信息下载到本地

    git clone  git address

    2.进入git项目的本地文件夹,将自己的项目复制到这个git 文件夹,查看状态,提交所有的新文件

    git status 

    git add -A

    git commit -a -m"first commit"

    3.上传更新到git 版本库

    git push

    注:git add上传本地项目所有变化的命令三种有 git add -Agit add -ugit add .

    git add -A  提交所有变化

    git add -u  提交被修改(modified)和被删除(deleted)文件,不包括新文件(new)

    git add .  提交新文件(new)和被修改(modified)文件,不包括被删除(deleted)文件

    参考git add -A git add . 的区别

    四、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

    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=]

               []

    available git commands in '/Applications/Xcode.app/Contents/Developer/usr/libexec/git-core'

      add                      merge-ours

      add--interactive          merge-recursive

      am                        merge-resolve

      annotate                  merge-subtree

      apply                    merge-tree

      archive                  mergetool

      bisect                    mktag

      bisect--helper            mktree

      blame                    mv

      branch                    name-rev

      bundle                    notes

      cat-file                  p4

      check-attr                pack-objects

      check-ignore              pack-redundant

      check-mailmap            pack-refs

      check-ref-format          patch-id

      checkout                  prune

      checkout-index            prune-packed

      cherry                    pull

      cherry-pick              push

      citool                    quiltimport

      clean                    read-tree

      clone                    rebase

      column                    rebase--helper

      commit                    receive-pack

      commit-tree              reflog

      config                    remote

      count-objects            remote-ext

      credential                remote-fd

      credential-cache          remote-ftp

      credential-cache--daemon  remote-ftps

      credential-osxkeychain    remote-http

      credential-store          remote-https

      daemon                    remote-testsvn

      describe                  repack

      diff                      replace

      diff-files                request-pull

      diff-index                rerere

      diff-tree                reset

      difftool                  rev-list

      difftool--helper          rev-parse

      fast-export              revert

      fast-import              rm

      fetch                    send-email

      fetch-pack                send-pack

      filter-branch            sh-i18n--envsubst

      fmt-merge-msg            shell

      for-each-ref              shortlog

      format-patch              show

      fsck                      show-branch

      fsck-objects              show-index

      gc                        show-ref

      get-tar-commit-id        stage

      grep                      stash

      gui--askpass              status

      hash-object              stripspace

      help                      submodule

      http-backend              submodule--helper

      http-fetch                subtree

      http-push                svn

      imap-send                symbolic-ref

      index-pack                tag

      init                      unpack-file

      init-db                  unpack-objects

      instaweb                  update-index

      interpret-trailers        update-ref

      log                      update-server-info

      ls-files                  upload-archive

      ls-remote                upload-pack

      ls-tree                  var

      mailinfo                  verify-commit

      mailsplit                verify-pack

      merge                    verify-tag

      merge-base                web--browse

      merge-file                whatchanged

      merge-index              worktree

      merge-octopus            write-tree

      merge-one-file

    git commands available from elsewhere on your $PATH

      cvsserver

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

    concept guides. See 'git help ' or 'git help '

    to read about a specific subcommand or concept.

    相关文章

      网友评论

          本文标题:2018-08-09 Git命令使用问题和FAQ

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