Search code examples
gitversion-controlbitbucketgit-pull

How can I check the changes between my local GIT repository and the remote one?


I am not so into GIT and I have the following problem.

I have a repository on BitBucket and I have to "update" my project to the latest version of the project on the BitBucket repository.

So I tried to perform the git pull statment but I am obtaining this message:

$ git pull
remote: Counting objects: 8, done.
remote: Compressing objects: 100% (5/5), done.
remote: Total 8 (delta 3), reused 0 (delta 0)
Unpacking objects: 100% (8/8), done.
From https://bitbucket.org/akakunin/userreg
   ef0c08d..692dc31  master     -> origin/master
error: Your local changes to the following files would be overwritten by merge:
        userreg-esb/src/main/synapse-config/api/user_registration.xml
Please commit your changes or stash them before you merge.
Aborting
Updating ef0c08d..692dc31

So my doubts are:

1) How can I check what files are changed between my local repository and the BitBucket one?

2) How can I check these changes? (I want to know what line of codes are changed and what file are added\deleted between my local repository and the BitBucket version)


Solution

  • The error message tells you which files stop the pull request:

    userreg-esb/src/main/synapse-config/api/user_registration.xml

    More details how you can diff the changes can be found in the answer of @Code-Apprentice:

    If [remote-path] and [local-path] are the same, you can do

    $ git fetch origin master

    $ git diff origin/master -- [local-path]

    Note 1: The second command above will compare against the locally stored remote tracking branch. The fetch command is required to update the remote tracking branch to be in sync with the contents of the remote server. Alternatively, you can just do

    $ git diff master:<path-or-file-name>

    Note 2: master can be replaced in the above examples with any branch name