On Fri, May 13, 2016 at 11:28 AM, 李本超 <libenchao@xxxxxxxxx> wrote: > git version 2.6.4 (Apple Git-63) > system version: OS X EI Capitan 10.11.4 > > below is the steps: > $ mkdir test_repo > $ cd test_repo > $ git init > $ echo "hello" > README.md > $ git commit -a -m 'Add README.md' It was my mistake. git-commit -a adds files which are tracked. Currently README.md is not tracked. So you will have to first use git-add to add them for tracking. Though while trying out your steps I used git-add. For further commits one can use -a with git-commit. > $ git checkout -b A > $ echo "world" > README.md > $ git commit -a -m 'Add one line' You are technically not adding a line. You are modifying the previous line to the updated line. So the contents of the file will be: "world" It seems from the further part that you actually wanted to add the line rather than modifying it. Better to use ">>" instead of ">". ">>" is used for appending. > $ git checkout master > $ git checkout -b B > $ echo "world" > README.md > $ git commit -a -m 'Add one line too' > $ [midify 'world' line to other things like 'git' using vi] I think you mean modify. > $ git commit -a -m 'Modify one line' > > $ git checkout master > $ git merge A > > $ git checkout B > $ git rebase master [problem is here, cat README.rd we will get : > hello and git instead of hello world git] The git behavior is quite correct. When you are on the B branch and you choose to rebase it on the master, it will apply commits as patches. So it first sees that the commit on the A branch which is now merged with master ie. "Add one line" and the commit on the B branch "Add one line too" are doing the same thing which is removing the line "hello" and adding the line "world". Then it applies the commit "modify one line" on top of this which removes the line "world" and adds the line "git". So finally, README.md will contain only "git". Regards, Pranit Bauva -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html