整理自Git文件夹下资料及man手册(不包括书籍)
$ git commit -a
which will automatically notice any modified (but not new) files, add them to the index, and commit, all in one step.
A note on commit messages: Though not required, it’s a good idea to begin the commit message with a single short (less than 50 character) line summarizing the change, followed by a blank line and then a more thorough description. Tools that turn commits into email, for example, use the first line on the Subject: line and the rest of the commit in the body.
If you also want to see complete diffs at each step, use
$ git log -p
Often the overview of the change is useful to get a feel of each step
$ git log --stat --summary
bai@bbox:~/t-git/push1$ git log --stat --summary --oneline
f441901 modified pushfile1 and touch a new file1
pushfile1 | 2 ++
1 file changed, 2 insertions(+)
ece9c28 changed pushfile1
pushfile1 | 1 +
1 file changed, 1 insertion(+)
8832efc changed pushfile1
pushfile1 | 1 +
1 file changed, 1 insertion(+)
d8ff449 add pushfile1 in push1
0 files changed
create mode 100644 pushfile1
73a5adf inital commit
0 files changed
create mode 100644 README
bai@bbox:~/t-git/push1$
In git 1.7.0 or later, to cancel a conflicting merge, use git reset --merge. Warning: In older versions of git, running git pull with
uncommitted changes is discouraged: while possible, it leaves you in a state that may be hard to back out of in the case of a conflict.
If any of the remote changes overlap with local uncommitted changes, the merge will be automatically cancelled and the work tree untouched.
It is generally best to get any local changes in working order before pulling or stash them away with git-stash(1).
Alice can peek at what Bob did without merging first, using the "fetch" command; this allows Alice to inspect what Bob did, using a special symbol "FETCH_HEAD", in order to determine if he has anything worth pulling, like this:
alice$ git fetch /home/bob/myrepo master
alice$ git log -p HEAD..FETCH_HEAD
This operation is safe even if Alice has uncommitted local changes. The range notation "HEAD..FETCH_HEAD" means "show everything that is reachable from the FETCH_HEAD but exclude anything that is reachable from HEAD". Alice already knows everything that leads to her current state (HEAD), and reviews what Bob has in his state (FETCH_HEAD) that she has not seen with this command.
Alice may want to view what both of them did since they forked. She can use three-dot form instead of the two-dot form:
$ gitk HEAD...FETCH_HEAD
This means "show everything that is reachable from either one, but exclude anything that is reachable from both of them".
Note that first line of each git log entry also gives a name for the commit:
$ git log
commit c82a22c39cbc32576f64f5c6b3f24b99ea8149c7
Author: Junio C Hamano <junkio@cox.net>
Date: Tue May 16 17:18:22 2006 -0700
merge-base: Clarify the comments on post processing.
We can give this name to git show to see the details about this commit.
$ git show c82a22c39cbc32576f64f5c6b3f24b99ea8149c7
But there are other ways to refer to commits. You can use any initial part of the name that is long enough to uniquely identify the commit:
$ git show c82a22c39c # the first few characters of the name are
# usually enough
$ git show HEAD # the tip of the current branch
$ git show experimental # the tip of the "experimental" branch
Every commit usually has one "parent" commit which points to the previous state of the project:
$ git show HEAD^ # to see the parent of HEAD
$ git show HEAD^^ # to see the grandparent of HEAD
$ git show HEAD~4 # to see the great-great grandparent of HEAD
Note that merge commits may have more than one parent:
$ git show HEAD^1 # show the first parent of HEAD (same as HEAD^)
$ git show HEAD^2 # show the second parent of HEAD
Any git command that needs to know a commit can take any of these names. For example:
$ git diff v2.5 HEAD # compare the current HEAD to v2.5
$ git branch stable v2.5 # start a new branch named "stable" based
# at v2.5
$ git reset --hard HEAD^ # reset your current branch and working
# directory to its state at HEAD^
Many git commands also take sets of commits, which can be specified in a number of ways. Here are some examples with git log:
$ git log v2.5..v2.6 # commits between v2.5 and v2.6
$ git log v2.5.. # commits since v2.5
$ git log --since="2 weeks ago" # commits from the last 2 weeks
$ git log v2.5.. Makefile # commits since v2.5 which modify
# Makefile
You can also give git log a "range" of commits where the first is not necessarily an ancestor of the second; for example, if the tips of the branches "stable" and "master" diverged from a common commit some time ago, then
$ git log stable..master
will list commits made in the master branch but not in the stable branch, while
$ git log master..stable
will show the list of commits made on the stable branch but not the master branch.
Finally, most commands that take filenames will optionally allow you to precede any filename by a commit, to specify a particular version of the file:
$ git diff v2.5:Makefile HEAD:Makefile.in
You can also use git show to see any such file:
$ git show v2.5:Makefile
<describeOutput>, e.g. v1.7.4.2-679-g3bee7fb
Output from git describe; i.e. a closest tag, optionally followed by a dash and a number of commits, followed by a dash, a g, and an
abbreviated object name.
The number of additional commits is the number of commits which would be displayed by "git log v1.0.4..parent". The hash suffix is "-g" +
7-char abbreviation for the tip commit of parent (which was 2414721b194453f058079d897d13c4e377f92dc6). The "g" prefix stands for "git" and
is used to allow describing the version of a software depending on the SCM the software is managed with. This is useful in an environment
where people may use different SCMs.
<rev>:<path>, e.g. HEAD:README, :README, master:./README
A suffix : followed by a path names the blob or tree at the given path in the tree-ish object named by the part before the colon. :path
(with an empty part before the colon) is a special case of the syntax described next: content recorded in the index at the given path. A
path starting with ./ or ../ is relative to the current working directory. The given path will be converted to be relative to the
working tree’s root directory. This is most useful to address a blob or tree from a commit or tree that has the same tree structure as
the working tree.
<refname>, e.g. master, heads/master, refs/heads/master
A symbolic ref name. E.g. master typically means the commit object referenced by refs/heads/master. If you happen to have both
heads/master and tags/master, you can explicitly say heads/master to tell git which one you mean.
HEAD names the commit on which you based the changes in the working tree. FETCH_HEAD records the branch which you fetched from a
remote repository with your last git fetch invocation. ORIG_HEAD is created by commands that move your HEAD in a drastic way, to
record the position of the HEAD before their operation, so that you can easily change the tip of the branch back to the state before
you ran them. MERGE_HEAD records the commit(s) which you are merging into your branch when you run git merge. CHERRY_PICK_HEAD
records the commit which you are cherry-picking when you run git cherry-pick.
Note that any of the refs/* cases above may come either from the $GIT_DIR/refs directory or from the $GIT_DIR/packed-refs file.
G H I J
\ / \ /
D E F
\ | / \
\ | / |
\|/ |
B C
\ /
\ /
A
A = = A^0
B = A^ = A^1 = A~1
C = A^2 = A^2
D = A^^ = A^1^1 = A~2
E = B^2 = A^^2
F = B^3 = A^^3
G = A^^^ = A^1^1^1 = A~3
H = D^2 = B^^2 = A^^^2 = A~2^2
I = F^ = B^3^ = A^^3^
J = F^2 = B^3^2 = A^^3^2
To exclude commits reachable from a commit, a prefix ^ notation is used. E.g. ^r1 r2 means commits reachable from r2 but exclude the ones
reachable from r1.
The r1^@ notation means all parents of r1.r1^! includes commit r1 but excludes all of its parents.
Here are a handful of examples:
D G H D
D F G H I J D F
^G D H D
^D B E I J F B
B...C G H D E B C
^D B C E I J F B C
C^@ I J F
F^! D G H D F
The first and second above is sometimes wrong,e.g.
git cherry-pick master
Apply the change introduced by the commit at the tip of the master branch and create a new commit with this change.
git cherry-pick master~4 master~2
Apply the changes introduced by the fifth and third last commits pointed to by master and create 2 new commits with these changes.
git cherry-pick -n master~1 next
Apply to the working tree and the index the changes introduced by the second last commit pointed to by master and by the last commit
pointed to by next, but do not create any commit with these changes.
git diff [--options] <commit> <commit> [--] [<path>...]
This is to view the changes between two arbitrary <commit>.
git diff [--options] <commit>..<commit> [--] [<path>...]
This is synonymous to the previous form. If <commit> on one side is omitted, it will have the same effect as using HEAD instead.
git diff [--options] <commit>...<commit> [--] [<path>...]
This form is to view the changes on the branch containing and up to the second <commit>, starting at a common ancestor of both
<commit>. "git diff A...B" is equivalent to "git diff $(git-merge-base A B) B". You can omit any one of <commit>, which has the same
effect as using HEAD instead.
For a more complete list of ways to spell <commit>, see "SPECIFYING REVISIONS" section in gitrevisions(7). However, "diff" is about
comparing two endpoints, not ranges, and the range notations ("<commit>..<commit>" and "<commit>...<commit>") do not mean a range as
defined in the "SPECIFYING RANGES" section in gitrevisions(7).
Create a bare repository to publish your changes to the public:
$ git clone --bare -l /home/proj/.git /pub/scm/proj.git
So,bare repository 应该是用来作为中心服务器上的公共repo来使用的,在工作机上最好用带有workig tree的repo.
refs:heads,remotes,tags
object:commit,tree,blob
<<<<<<<<<<《GIt Community》
分支(branch), 远程跟踪分支(remote-tracking branch)以及标签(tag)都是对提交的引用. 所有的引用是用"refs"开头, 以斜杠分割的路径. 到目前为此, 我们用到的引用名称其实是它们的简写版本:
- 分支"test"是"refs/heads/test"的简写.
- 标签"v2.6.18"是"refs/tags/v2.6.18"的简写.
- "origin/master"是"refs/remotes/origin/master"的简写.
每个对象(object) 包括三个部分:类型 大小和内容。大小就是指内容的大小,内容取决于对象的类型,有四种类型的对象:"blob"、"tree"、 "commit" 和"tag"。
• “blob”用来存储文件数据,通常是一个文件。
• “tree”有点像一个目录,它管理一些“tree”或是 “blob”(就像文件和子目录)
• 一个“commit”只指向一个"tree",它用来标记项目某一个特定时间点的状态。它包括一些关于时间点的元数据,如时间戳、最近一次提交的作者、指向上次提交(commits)的指针等等。
• 一个“tag”是来标记某一个提交(commit) 的方法。
commit
• 作者 : 做了此次修改的人的名字, 还有修改日期.
• 提交者
提交者(committer): 实际创建提交(commit)的人的名字, 同时也带有提交日期. TA可能会和作者不是同一
个人; 例如作者写一个补丁(patch)并把它用邮件发给提交者, 由他来创建提交(commit).
一个标签对象包括一个对象名(译者注:就是SHA1签名), 对象类型, 标签名, 标签创建人的名字("tagger"), 还有一条可能包含有签名(signature)的消息
点击 git tag, 可以了解如何创建和验证标签对象. (注意: git tag 同样也可以用来创建 "轻量级的标签"(lightweight tags),但它们并不是标签对象, 而只一些以 "refs/tags/" 开头的引用罢了).
If one of -a, -s, or -u <key-id> is passed, git tag creates a tag object, and requires a tag message.Otherwise just a tag reference for the SHA1 object name of the commit object is created (i.e. a lightweight tag).
In general, it's very important to write a good commit message. For open source projects, it's generally a rule to write your message more or less in this format:
Short (50 chars or less) summary of changes
More detailed explanatory text, if necessary. Wrap it to about 72
characters or so. In some contexts, the first line is treated as the
subject of an email and the rest of the text as the body. The blank
line separating the summary from the body is critical (unless you omit
the body entirely); some git tools can get confused if you run the
two together.
Further paragraphs come after blank lines.
- Bullet points are okay, too
- Typically a hyphen or asterisk is used for the bullet, preceded by a
single space, with blank lines in between, but conventions vary
here
# Please enter the commit message for your changes. Lines starting
# with '#' will be ignored, and an empty message aborts the commit.
# On branch master
# Changes to be committed:
# (use "git reset HEAD <file>..." to unstage)
#
# modified: hello.rb
#
~
~
~
".git/COMMIT_EDITMSG" 25L, 884C written
· References to commit objects at the head of each branch are stored in files under .git/refs/heads/.
· The name of the current branch is stored in .git/HEAD.
So,"merging upwards" means being merged to the upstream,e.g. linus merges other maintainers' branches(cherry-pick),while other developers get linux mainline using git merge,which calls "merging downwards".<<<<man Gitworkflows
整理自Git文件夹下资料及man手册(不包括书籍)的更多相关文章
- git文件夹下项目更改ip地址小结
在我们开发的过程中,经常切换项目IP地址是很正常的,之前弄过一次,没有记住,现在简单的总结下: 找到要切换IP地址的项目,点击鼠标右键,弹出下图: 打开该项目的路径后,双击打开该项目,具体参考自己项目 ...
- git 无法添加文件夹下文件
最近做项目时,发现无法提交某个子文件夹下的文件. google后发现可能是该子文件夹下有.git文件夹导致无法上传. 删除子文件夹下.git后,依然无法提交子文件夹下的文件. 继续google, 尝试 ...
- git 命令添加整个文件夹以及文件夹下的内容
对于一个文件夹提交到服务器上,喜欢用 git add .(后面为".") 这种情况对于一个文件夹的还是很有用的,但出现了多个不同文件夹后,要分别提交就不能这么用了, 可以使用如下指 ...
- Shell 命令行,写一个自动整理 ~/Downloads/ 文件夹下文件的脚本
Shell 命令行,写一个自动整理 ~/Downloads/ 文件夹下文件的脚本 在 mac 或者 linux 系统中,我们的浏览器或者其他下载软件下载的文件全部都下载再 ~/Downloads/ 文 ...
- git fetch批处理,遍历一个文件夹下的所有子目录,执行git fetch --all
echo off for /d %%i in (*) do ( echo %%i cd %%i git fetch --all cd .. ) 判断子目录是否有.git文件夹 echo off for ...
- 【问题解决方案】在某个文件夹下打开命令提示符或Git Bash
参考链接: 百度知道:怎么在某个文件夹下打开命令提示符 问题: 当文件夹比较深时,一直cd进入文件夹内部就显得非常迟缓了. 解决: cmd:打开所需文件夹路径后,在上面的路径显示框中输入CMD,然后回 ...
- Projects\Portal_Content\Indexer\CiFiles文件夹下文件占用磁盘空间过大问题。
C:\Program Files\Microsoft Office Servers\12.0\Data\Office Server\Applications\9765757d-15ee-432c-94 ...
- 统计文件夹下java代码行数的小程序--主要是学习任务队列的思想
首先感谢czbk的老师,录制的视频,让我们有这么好的学习资料.……—— 统计文件夹java文件的行数,首先想到的肯定是用递归的方法,因为文件夹下面可能包含文件夹,用递归的方法,代码容易写.(这和写简单 ...
- 从.git文件夹探析git实现原理
git是一款分布式代码版本管理工具,通过git能够更加高效地协同编程.了解git的工作原理将有助于我们使用git工具更好地管理项目.通过了解.git文件夹中的文件组成,我们可以从一个角度去窥探git的 ...
随机推荐
- BZOJ-1085 骑士精神
估价函数其实就是与目标状态有几个不同... 迭代启发搜索. #include <cstdlib> #include <cstdio> #include <cstring& ...
- AC自动机详解 (P3808 模板)
AC自动机笔记 0.0 前言 哇,好久之前就看了 KMP 和 Trie 树,但是似乎一直没看懂 AC自动机?? 今天灵光一闪,加上之前看到一些博客和视频,瞬间秒懂啊... 其实这个玩意还是蛮好理解的. ...
- 【基础操作】2-sat
$2-sat$ 是一个很不怎么考的内容($NOI2017$ 除外) 例题
- Junit框架使用--JUnit常用断言及注解
从别人博客中抄过来一点东西 原文地址:http://blog.csdn.net/wangpeng047/article/details/9628449 断言是编写测试用例的核心实现方式,即期望值是多少 ...
- docker基础——自定义镜像、创建私有仓库、查看 docker 运行状态
一.自定义镜像 1,案例1 要求:请自定义一个 docker 镜像,基于 hub.c.163.com/library/centos,要求创建出来的镜像在生成容器的时候,可以直接使用 ifconfig ...
- hdu 1695 容斥原理或莫比乌斯反演
GCD Time Limit: 6000/3000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submiss ...
- 【CF1016B】Segment Occurrences(模拟)
题意:给定两个串s和t,多次询问s的一个区间[l ,r]中有多少个子串与t串相同 len<=1e3,q<=1e5 思路:前缀和 #include<cstdio> #includ ...
- JVM指令助记符
以下只是JVM指令助记符,关于JVM指令的详细内容请阅读<JVM指令详解> 变量到操作数栈:iload,iload_,lload,lload_,fload,fload_,dload,dlo ...
- 洛谷——P2701 [USACO5.3]巨大的牛棚Big Barn
P2701 [USACO5.3]巨大的牛棚Big Barn 题目背景 (USACO 5.3.4) 题目描述 农夫约翰想要在他的正方形农场上建造一座正方形大牛棚.他讨厌在他的农场中砍树,想找一个能够让他 ...
- XSY1659 [HNOI2012]永无乡
题面 Description 永无乡包含 n 座岛,编号从 1 到 n. 每座岛都有自己的独一无二的重要度,按照重要度可以将这n座岛排名,名次用 1到n来表示.某些岛之间由巨大的桥连接,通过桥可以从一 ...