ITPub博客

首页 > Linux操作系统 > Linux操作系统 > GIT

GIT

原创 Linux操作系统 作者:jinh2019 时间:2009-07-02 10:42:43 0 删除 编辑

历史

安装

使用

命令格式

按照常规,寻求帮助。

git --help 或者 git -h

git [--version] [--exec-path[=GIT_EXEC_PATH]] [-p|--paginate|--no-pager] [--bare] [--git-dir=GIT_DIR] [--work-tree=GIT_WORK_TREE] [--help] COMMAND [ARGS]

The most commonly used git commands are:
   add        Add file contents to the index
   bisect     Find the change that introduced a bug by binary search
   branch     List, create, or delete branches
   checkout   Checkout and switch to a branch
   clone      Clone a repository into a new directory
   commit     Record changes to the repository
   diff       Show changes between commits, commit and working tree, etc
   fetch      Download objects and refs from another repository
   grep       Print lines matching a pattern
   init       Create an empty git repository or reinitialize an existing one
   log        Show commit logs
   merge      Join two or more development histories together
   mv         Move or rename a file, a directory, or a symlink
   pull       Fetch from and merge with another repository or a local branch
   push       Update remote refs along with associated objects
   rebase     Forward-port local commits to the updated upstream head
   reset      Reset current HEAD to the specified state
   rm         Remove files from the working tree and from the index
   show       Show various types of objects
   status     Show the working tree status
   tag        Create, list, delete or verify a tag object signed with GPG

 

Within a repository, Git maintains two primary data structures, the object store and
the index. All of this repository data is stored at the root of your working directory in
a hidden subdirectory named .git.

If two separate files located in two different directories have exactly the same content,
Git stores a sole copy of that content as a blob within the object store. Git computes
the hash code of each file according solely to its content, determines that the files have
the same SHA1 values and thus the same content, and places the blob object in the
object store indexed by that SHA1 value. Both files in the project, regardless of where
they are located in the user’s directory structure, use that same object for content.

As with many other VCSs, Git needs to maintain an explicit list of files that form. the
content of the repository. However, this does not require that Git’s manifest be based
on filenames. Indeed, Git treats the name of a file as a piece of data that is distinct from
the contents of that file. In this way, it separates “index” from “data” in the traditional
database sense.

As mentioned earlier, Git tracks the pathnames of files through another kind of object
called a tree. When you use git add, Git creates an object for the contents of each file
you add, but it doesn’t create an object for your tree right away. Instead, it updates the
index. The index is found in .git/index and keeps track of file pathnames and corresponding
blobs. Each time you run commands such as git add, git rm, or git mv, Git
updates the index with the new pathname and blob information.

Git’s index doesn’t contain any file content; it simply tracks what you want to commit.

run git add to update the index with
the absolute latest and greatest version of your file

Whereas git rm --cached removes the file from the index and leaves it in the working
directory, git rm removes the file from both the index and the working directory.

Before Git removes a file, it checks to make sure the version of the file in the working
directory matches the latest version in the current branch (the version that Git commands
call the HEAD).

git add data

git checkout HEAD -- data

The unique, 40-
hex-digit SHA1 commit ID is an explicit reference, while HEAD, which always points to
the most recent commit, is an implied reference.

 

 

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/465626/viewspace-608128/ ,如需转载,请注明出处,否则将追究法律责任。

上一篇: What is Android
下一篇: 没有了~
请登录后发表评论 登录
全部评论

注册时间:2009-07-01

  • 博文量
    2
  • 访问量
    1512

最新文章