I am seeing a strange behaviour, I don't know if it is a bug or a feature.
From machine #1 I do git reset --hard someCommit && git push -f
. The reset is then propagated to all machine (I can see the change by doing a git pull
or git log
from another machine).
From machine #2 that runs JGit I perform: git.pull().call()
but the reset is not applied and the files on disk are not changed. Also git.log().call()
does not point to the reverted commit.
What am I doing wrong?
Like Tim described, you likely need to force fetch on the other computers.
The return value of PushCommand::call()
will tell you if and why the push did not succeed.
To force pull in JGit, follow this example:
git.fetch()
.setForce( true )
.setRefSpec( new RefSpec( "refs/heads/someBranch:refs/remotes/origin/someBranch" ) )
.call();
git.reset()
.setMode( ResetType.HARD )
.setRef( "someBranch" )
.call();