<-Previous || RM Table of Content ||
Push and Merge errors
Push errors may occur when a developer pushes changes after another developer has already pushed other changes to the remote repository. Since the local history has diverged from the remote repository, Git generates an error like below:
error: failed to push some refs to 'https://xxxxxx@stash.uconn.edu/scm/AiMIntegrationBrokerWS/AiMIntegrationBrokerWS.git'
hint: Updates were rejected because the tip of your current branch is behind hint: its remote counterpart. Integrate the remote changes (e.g. hint: 'git pull ...') before pushing again. hint: See the 'Note about fast-forwards' in 'git push --help' for details.
In this case the developer needs to pull the updates from the central repository by
- Click the Pull button in SourceTree (make sure the check box “Rebase…” is checked) and click the OK button as shown below. The –rebase option tells Git to move the commit(s) to the tip of the test branch.
Merge conflict occurs:
CONFLICT (content): Merge conflict in xxxx/yyyy.java - Open the file in any editor (See the example below) Git automatically adds markers to mark changes from different sources:
<<<<<<< HEAD import javax.servlet.http.HttpServletRequest; ======= import javax.servlet.http.HttpServletResponse; >>>>>>> Just a test
Text from <<<<<<< HEAD to ======= comes from the remote repository. And the rest comes from the local changes. Note that “Just a test” is the commit message entered by the developer. More specifically, the developer codes the line
import javax.servlet.http.HttpServletResponse;
While the changes made by the other developer that came from the remote repository is
import javax.servlet.http.HttpServletRequest;
- Edit the file as necessary after a discussion with the other developer (for example keep the change import javax.servlet.http.HttpServletRequest;), save the file. Right click the file in the Unstaged files area in SourceTree, select Resolve Conflicts->Mark Resolved.
Note: Two quick shortcuts for resolving conflicts are to use Resolve Using Mine, and Resolve Using Theirs to use the change from self or from the other developer. - Hit OK button to close the Confirm dialog below:
- Hit Commit button. Hit Continue Rebase button
- The conflict was resolved in the local repository. Test branch should be ahead and there is a push notification. Click the Push button in SourceTree to push the changes to the test branch of the remote repository. On the Push dialog, click the Push button.
Unwanted Uncommitted Changes
The developer may create changes locally accidently and want to discard them.
- Right click to select “Uncommitted changes”, select Discard.
2. Hit OK button on the Confirm Discard dialog
Unwanted Commits
You may want to reset your local branch to remove unwanted commit. In SourceTree, make sure test branch is checked out, select the commit you want to be on the top, right click and select Reset current branch to this commit. You may have to close/re-open SourceTree to see the refreshed commit graph.
Non-Versioned Files
Files that are created by the IDE are not needed in Git. If seeing the files in SourceTree, simply right click (or Ctrl-Click in Mac OS X), and select Ignore
Then select Ignore exact file name in the following dialog.