在阅读的手册页git的樱桃挑选,我的理解是,它只需通过一个引入的变革承诺,然后你几乎可以在任何地方应用这些更改.
所以,假设我有一个文件,我建立了超过4次提交,如下所示:
line from commit 1
line from commit 2
line from commit 3
line from commit 4
Run Code Online (Sandbox Code Playgroud)
如果我然后在提交1开始另一个分支,我应该能够到达
line from commit 1
line from commit 4
Run Code Online (Sandbox Code Playgroud)
通过在提交4中采摘樱桃
如果我有这个权利,为什么它不起作用?我得到了一个冲突,然后当我看到冲突时,看起来好像git试图从提交2,3,4中引入行.这是我工作的日志(跳到这里吃肉看看肉......):
szbwood-mbp15:proj5 bwood$ git init
Initialized empty Git repository in /Users/bwood/work/gitplay/proj5/.git/
szbwood-mbp15:proj5 bwood$ vi file1
szbwood-mbp15:proj5 bwood$ git add file1
szbwood-mbp15:proj5 bwood$ git commit -a
[master (root-commit) 4cb9b97] ..
1 files changed, 1 insertions(+), 0 deletions(-)
create mode 100644 file1
szbwood-mbp15:proj5 bwood$ vi file1
szbwood-mbp15:proj5 bwood$ git commit -a
[master 809d87c] .. …Run Code Online (Sandbox Code Playgroud) 如果我做
git checkout -b samename origin/samename
Run Code Online (Sandbox Code Playgroud)
然后跟踪似乎工作正常.如果我做后续提交,我就可以做
git push
Run Code Online (Sandbox Code Playgroud)
并且git将我的提交推迟到原点.
但是,如果我这样做
git checkout -b diffname origin/samename
Run Code Online (Sandbox Code Playgroud)
然后跟踪不起作用,尽管pro git书的这一部分:
$ git checkout -b sf origin/serverfix
Branch sf set up to track remote branch refs/remotes/origin/serverfix.
Switched to a new branch "sf"
Now, your local branch sf will automatically push to and pull from origin/serverfix
Run Code Online (Sandbox Code Playgroud)
Git push只是给出了"一切都是最新的"给出了什么?
我在mac os x上运行git 1.7.1
以下是那些想在家尝试的人的整个实验:
szbwood-mbp15:proj4_local bwood$ vi file1
szbwood-mbp15:proj4_local bwood$ git add file1
szbwood-mbp15:proj4_local bwood$ git commit -m"Created file 1"
[master (root-commit) 5d50289] Created file …Run Code Online (Sandbox Code Playgroud) git ×2