PHP Release Management Process – Common Issues with Git (Windows)

<-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 ''
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

  1. 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.php
  2. Open the file in any editor (See the example below) Git automatically adds markers to mark changes from different sources:
    <<<<<<< HEAD
    >>>>>>> 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


    While the changes made by the other developer that came from the remote repository is


  3. Edit the file as necessary after a discussion with the other developer (for example keep the change print_r($_GET);), save the file. Right click the file in the Unstaged files area in SourceTree, select Resolve Conflicts->Mark Resolved.

    Note: Two quick shortcuts for steps b and c are to use Resolve Using Mine, and Resolve Using Theirs to use the change from self or from the other developer.
  4. Hit OK button to close the Confirm dialog below:
  5. Hit Commit button. Hit Continue Rebase button
  6. 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.

  1. Click to select “Uncommitted changes”. Right click the file(s) in Unstaged Files, 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.