Any explanation about how git p4 rebase works?
I would say I do not understand the behavior of Git p4 rebase command at all. From the document and source code of git-p4 command, it just does a "git p4 sync" to update refs/remotes/p4/master branch and "git rebase refs/remotes/p4/master", then the already applied commits in local branches get recognized, and unapplied commits can be submitted soon.
But since the refs/remotes/p4/master branch comes from Perforce, the commit hash is different from local branch. In this case how Git knows two commits in local branch and remote P4 branch is actually same?
Let's say you clone a new repository, create a new branch, do some work and commit:
git clone [repository_address] git checkout -b mybranch touch tmp.txt echo "Hello World" > tmp.txt git commit -am 'Edited tmp.txt file'
And in the meantime, another contributor of the remote repository performs some work and commits, making the hash of the remote master branch changed.
At this point, if you run the rebase command, you should get a result like
mybranch is already up-to-date
That's because, the hash of your local master branch hasn't changed.
Now you go back to your master branch and run the git fetch command.
git checkout master git fetch origin
From this point, the git rebase master command on mybranch should do sth new because the head of your local master branch moved forward.