Reputation: 383
Beside merging branches, GIT can have conflicts by
How can I list this conflicts before the push or pull and mark them as fixed?
I tried using Git.status(), and expected to see this files under conflicts, but nothing is listed.
Status status = git.status().call();
status.getConflicting();
Here are some code snippets I use:
git.pull().setContentMergeStrategy(ContentMergeStrategy.CONFLICT).setCredentialsProvider( new FxGitCredentialsProvider( getDialogScene() )).call();
final AddCommand addCommand = git.add();
for ( String filePattern : filePatterns){
addCommand.addFilepattern( filePattern );
}
addCommand.call();
git.commit().setMessage(messageTextArea.getText()).setCredentialsProvider( new FxGitCredentialsProvider( getDialogScene() )).call();
if ( push ){
PushCommand pushCommand = git.push().setCredentialsProvider( new FxGitCredentialsProvider( getDialogScene()));
pushCommand.call();
}
Upvotes: 1
Views: 194
Reputation: 51870
Two clarifications :
git push
doesn't trigger conflicts (not a file level conflict as a merge
would do), it just refuses to update a branch if the commit you are pushing is not a fast forward of the existing branch tip
git pull
is actually a 2 steps command : git fetch
, which recovers the commits from the remote repository, followed by git merge <upstream branch>
conflicts may be triggered by the second step (a regular git merge
)
There are other commands that may trigger conflicts: git cherry-pick
and git rebase
To fix issues with 1.
: you won't see anything by running git status
, you should update your view of the remote (git fetch
), inspect the history and select what to do:
probably run git merge <upstream/branch>
or git rebase <upstream/branch>
.
As said above: running git fetch
followed by git merge
is the same as running git pull
, the difference is that you can inspect the state of your repo before running git merge
.
or force push : git push --force-with-lease origin
To fix issues with 2.
: you can run a regular merge conflict resolution.
Upvotes: 1