Sourcetree No Changes In This File Have Been Detected

Posted on by admin

By: Koen Verbeeck Updated: 2021-02-02 Comments Related: 1 2 3 More >DevOps

  1. Sourcetree No Changes In This File Have Been Detected Will
  2. Sourcetree No Changes In This File Have Been Detected

In SourceTree, selecting 'discard' on a file just throws away your local changes; stop tracking removes it from the repository. However, as long as you have deleted the file on your local drive, and you can see that deletion in the 'Staged Files' section of SourceTree, it will be deleted. The staging area (index) is a container where Git gathers all changes which will be part of the next commit. Editing a versioned file on the local machine, will be recognized by Git as a modified file and be called as unstaged. Staging the file will place the file into the staging area. The changes within the staging area are part of the next. SourceTree will no longer auto-refresh when changes are detected inside ignored directories. For this to work the directory itself needs to be ignored rather than the file that changed, since the Mac FSEvents notifier only includes directory information.


Problem

Sometimes when working on an Integration Services project with multiple developers,a merge conflict can occur in the git repository. In this tip, we'll showyou how to resolve this type of conflict and provide alternative options.

Solution

Inpart 1 of the tip, the basicsof git branching are described, as well as some best practices for using git inIntegration Services (SSIS) projects. Inpart 2, we demonstrated under what occasion a merge conflict can happen whenmerging two branches together. If you haven't already, please read bothparts before proceeding with this final part of the tip.

Resolve a Git Merge Conflict

When a merge conflict happens, the developer has a couple of choices:

  • Resolve the conflict while merging the branch to the dev branch.
  • First, pull the dev branch into the local branch to apply changes from otherdevelopers (which were already pushed to the dev branch). Then, the branch ismerged to the dev branch (the conflicts should've already been resolved).
  • Rebase the branch onto the dev branch. This means that all commits on thedev branch, since the branch was originally created, are applied to the branch(at the starting point). Then, all the commits of the local branch are applied.This resembles 'cutting' the branch from the dev branch and 'replanting'it on the dev branch at a later time.

Sourcetree No Changes In This File Have Been Detected Will

Resolve While Merging

If the conflict is not too complex, it can be resolved directly in the pull request.In the Pull Request page in the browser, you can go to the conflicts tabto view the files that have a merge conflict. If you don't see the conflictstab, it's possible you have to install thePull Request Merge Conflict Extension from Microsoft DevLabs first.

When you select one of the files in conflict, you'll get a preview of theconflict resolution at the right side of the screen. This is divided in three parts:on the left, the file from the source branch, on the right, from the destinationbranch, and at the bottom is the resulting file after conflict resolution.

Using the arrows in the top right, you can jump between different sections ofthe file that have a conflict. In the screenshot, you can see a conflict that wasresolved automatically by git. On the left, the new package is missing. On the right,the package is indicated in blue. In the resulting file, the package 'Package1.dtsx' has been added to the file.

There's a section git couldn't resolve automatically and this isindicated in red.

In the result, both options are still present and they are surrounded with <and > to mark the start and end of the conflict. The names of the branches arealso included. In most tools for resolving merge conflicts, you can easily chooseif you want the left or the right option. However, this currently is not possiblein the browser. You have to manually type in the bottom window to get the desiredresult. A possible solution could be this one:

Once the conflicts are resolved, you can hit 'Submit Merge' at thetop. If you're sure you don't need to actually merge, but rather justtake the source or destination file, you can select these using the buttons at thetop. For example, for the suo file we can take the target file:

Once the conflict is resolved, the pull request can be completed. The graph lookslike this:

Resolve by Pulling the Dev Branch

Another option is to pull the dev branch into the feature/add-task branch. Thiswill apply all commits from the dev branch which have happened after the add-taskbranch was created on this branch. The graph looks like this:

When the dev branch is pulled into the feature/add-task branch, a merge conflictwill be detected. Once you resolve it, the resolution will be committed on the feature/add-taskbranch. When you create a new pull request to merge the branch into dev, there willbe no conflict.

The advantage of this solution is that you can resolve the conflict on your ownbranch, not interfering with other people's work on the dev branch. If somethinggoes wrong during conflict resolution, only your branch has this problem and otherdevelopers are unaffected.

Resolve by Rebasing the Branch

When you 'rebase' your current working branch on the dev branch,it's like you are cutting your branch off and replanting it further down thetimeline. For example:

Here, the feature/add-task branch is rebased on dev. This means the branch isre-created and the point in time is after the feature/add-package was merged intothe dev branch (because that's the latest commit on the dev branch). Thismeans all commits on the dev branch are applied to the feature/add-task branch first(e.g. adding the new package). Then the actual commits of the branch are re-applied(adding a new-task). When this commit is applied, a merge conflict will be detectedand you can resolve it in the branch itself. Once it is resolved, you can createa pull request and merge the branch back into the dev branch.

Sourcetree No Changes In This File Have Been Detected

The difference between pulling the dev branch into your working branch or rebasingyour working branch on dev, is the chronological order in which commits are applied.

Sourcetree no changes in this file have been detected withoutSourcetree no changes in this file have been detected or it is a binary file sql
  • Pulling: first your own commits, then the commits of the dev branch.
  • Rebasing: first the commits of the dev branch, then your own commits.

Although the end result is most likely the same from a code point of view, rebasingtends to be preferred as it keeps 'branches clean'. You can rebase inVisual Studio by right-clicking the branch and selecting 'Rebase Onto…'.Make sure you select the correct source and destination branch.

Conclusion

In this three-part tip, we saw how you can use branching in a git repositoryto work with multiple developers on the same SSIS project. Using branching, developerscan work on different tasks without interfering with the work of others. One goldenrule is to never work on the same object at the same time. If a conflict does occur,we've shown you how to resolve it.

Next Steps
  • Other 3rdparty tools offer a better interface for handling git repositories and especiallyfor handling merge conflicts. There are free tools out there, such asFork andSourceTree.
  • If you haven't already, readpart 1andpart 2of this tip.
  • If you upgrade Visual Studio 2019 to the latest version, you might geta different look ‘n feel for the git user interface, depending onyour preview settings.
  • For more SSIS tips, check outthis overview.

Last Updated: 2021-02-02



About the author
Koen Verbeeck is a BI professional, specializing in the Microsoft BI stack with a particular love for SSIS.
View all my tips
Sourcetree No Changes In This File Have Been Detected
Related Resources

Version control systems are all about managing contributions between multiple distributed authors ( usually developers ). Sometimes multiple developers may try to edit the same content. If Developer A tries to edit code that Developer B is editing a conflict may occur. To alleviate the occurrence of conflicts developers will work in separate isolated branches. The git merge command's primary responsibility is to combine separate branches and resolve any conflicting edits.

Understanding merge conflicts

Merging and conflicts are a common part of the Git experience. Conflicts in other version control tools like SVN can be costly and time-consuming. Git makes merging super easy. Most of the time, Git will figure out how to automatically integrate new changes.

Conflicts generally arise when two people have changed the same lines in a file, or if one developer deleted a file while another developer was modifying it. In these cases, Git cannot automatically determine what is correct. Conflicts only affect the developer conducting the merge, the rest of the team is unaware of the conflict. Git will mark the file as being conflicted and halt the merging process. It is then the developers' responsibility to resolve the conflict.

Types of merge conflicts

A merge can enter a conflicted state at two separate points. When starting and during a merge process. The following is a discussion of how to address each of these conflict scenarios.

Git fails to start the merge

A merge will fail to start when Git sees there are changes in either the working directory or staging area of the current project. Git fails to start the merge because these pending changes could be written over by the commits that are being merged in. When this happens, it is not because of conflicts with other developer's, but conflicts with pending local changes. The local state will need to be stabilized using git stash, git checkout, git commit or git reset. A merge failure on start will output the following error message:

Git fails during the merge

A failure DURING a merge indicates a conflict between the current local branch and the branch being merged. This indicates a conflict with another developers code. Git will do its best to merge the files but will leave things for you to resolve manually in the conflicted files. A mid-merge failure will output the following error message:

File

Creating a merge conflict

In order to get real familiar with merge conflicts, the next section will simulate a conflict to later examine and resolve. The example will be using a Unix-like command-line Git interface to execute the example simulation.

This code example executes a sequence of commands that accomplish the following.

  • Create a new directory named git-merge-test, change to that directory, and initialize it as a new Git repo.
  • Create a new text file merge.txt with some content in it.
  • Add merge.txt to the repo and commit it.

Now we have a new repo with one branch master and a file merge.txt with content in it. Next, we will create a new branch to use as the conflicting merge.

The proceeding command sequence achieves the following:

  • create and check out a new branch named new_branch_to_merge_later
  • overwrite the content in merge.txt
  • commit the new content

With this new branch: new_branch_to_merge_later we have created a commit that overrides the content of merge.txt

This chain of commands checks out the master branch, appends content to merge.txt, and commits it. This now puts our example repo in a state where we have 2 new commits. One in the master branch and one in the new_branch_to_merge_later branch. At this time lets git merge new_branch_to_merge_later and see what happen!

BOOM 💥. A conflict appears. Thanks, Git for letting us know about this!

How to identify merge conflicts

As we have experienced from the proceeding example, Git will produce some descriptive output letting us know that a CONFLICT has occcured. We can gain further insight by running the git status command

The output from git status indicates that there are unmerged paths due to a conflict. The merge.text file now appears in a modified state. Let's examine the file and see whats modified.

Here we have used the cat command to put out the contents of the merge.txt file. We can see some strange new additions

  • <<<<<<< HEAD
  • >>>>>>> new_branch_to_merge_later

Think of these new lines as 'conflict dividers'. The line is the 'center' of the conflict. All the content between the center and the <<<<<<< HEAD line is content that exists in the current branch master which the HEAD ref is pointing to. Alternatively all content between the center and >>>>>>> new_branch_to_merge_later is content that is present in our merging branch.

How to resolve merge conflicts using the command line

The most direct way to resolve a merge conflict is to edit the conflicted file. Open the merge.txt file in your favorite editor. For our example lets simply remove all the conflict dividers. The modified merge.txt content should then look like:

Once the file has been edited use git add merge.txt to stage the new merged content. To finalize the merge create a new commit by executing:

Git will see that the conflict has been resolved and creates a new merge commit to finalize the merge.

Git commands that can help resolve merge conflicts

General tools

The status command is in frequent use when a working with Git and during a merge it will help identify conflicted files.

Passing the --merge argument to the git log command will produce a log with a list of commits that conflict between the merging branches.

diff helps find differences between states of a repository/files. This is useful in predicting and preventing merge conflicts.

Tools for when git fails to start a merge

checkout can be used for undoing changes to files, or for changing branches

reset can be used to undo changes to the working directory and staging area.

Tools for when git conflicts arise during a merge

Executing git merge with the --abort option will exit from the merge process and return the branch to the state before the merge began.

Git reset can be used during a merge conflict to reset conflicted files to a know good state

Summary

Merge conflicts can be an intimidating experience. Luckily, Git offers powerful tools to help navigate and resolve conflicts. Git can handle most merges on its own with automatic merging features. A conflict arises when two separate branches have made edits to the same line in a file, or when a file has been deleted in one branch but edited in the other. Conflicts will most likely happen when working in a team environment.

Ready to try branching?

Try this interactive tutorial.

Next up:

Git Merge Strategies

Start next tutorial