Page 1 of 1

Git plugin - see remote changes

Posted: Thu Apr 20, 2017 8:52 pm
by iwbnwif
The git plugin has a really nice "Show current diffs" feature that lets me see what I have changed locally compared to the remote branch.

It would be really nice if this could be reversed somehow to show what has changed on the remote branch compared to my local branch.

Is this possible inside Codelite? I know I can do it on the command line with:

Code: Select all

git fetch origin ; git diff --name-only master origin/master 
and

Code: Select all

git fetch origin ; git diff master origin/master mainframe.cpp
Sorry for my terminology, I am not a heavy user of git, but need to in this case because my project is on Github.

Re: Git plugin - see remote changes

Posted: Thu Apr 20, 2017 9:24 pm
by DavidGH
Hi,

Indeed, "Show current diffs" is very useful now, but it needs far more options e.g. to diff 2 particular commits, or between branches. It's on my (long) ToDo list...

I personally have never wanted to diff against origin, but it's good to know what others would like. It's unlikely to happen soon, but I'll add it to the list :)

Regards,

David

Re: Git plugin - see remote changes

Posted: Thu Apr 20, 2017 10:21 pm
by iwbnwif
Thanks David for the reply.

The reason for wanting this is to 'preview' what might happen during a

Code: Select all

git pull
.

It may well be my lack of knowledge regarding Git in general and the plugin in particular. Perhaps there is a better way of achieving the same thing.

Re: Git plugin - see remote changes

Posted: Thu Apr 20, 2017 11:17 pm
by DavidGH
The reason for wanting this is to 'preview' what might happen during a git pull
As you've just done 'git fetch', the changes are already 'pulled', meaning downloaded; they're just not been merged.

Seeing a diff for that would work if you were only a single commit behind origin, but would be increasingly noisy for more. I'd have thought that 'git log' would be worth doing first.
FWIW, one of the git aliases that I found online and use often is:

Code: Select all

lc = !LESS=FRSXE git log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --date=relative ORIG_HEAD.. --no-merges
i.e. it shows the top line of each commit message that 'git fetch' just fetched.

Adding that sort of thing to the git plugin's 'Browse Commit History' dialog might be possible. If so I think it would be a better place for it.

Re: Git plugin - see remote changes

Posted: Fri Apr 21, 2017 4:57 pm
by iwbnwif
Thank you for these explanations. I clearly need to do much more reading on the Git commands.

The problem that I thought I was experiencing is that a 'git pull' was silently overwriting my local files, losing all my recent changes. A straightforward 'git diff' doesn't really help because the diff could be because I have changed something, or the remote version has been updated.

If it is the case (as I think it must be), that a 'git pull' should not merge without some form of warning first, then maybe this is not really an issue at all.

As an aside, the local Git folder doesn't seem to be remembered and always defaults to the current project's folder. Therefore, I need to set it for each new Codelite session. I have my git'd source in a subfolder from the main project folder.

Re: Git plugin - see remote changes

Posted: Fri Apr 21, 2017 9:48 pm
by DavidGH
This is getting somewhat off topic here, but:
git fetch won't change your local files; it only updates git's information about origin
git merge does change local files. If you have uncommitted changes, it will refuse to try. If you have local commits to a relevant file, those changes won't be overwritten; if the merge can't avoid altering your changes to a file, it won't happen; instead it will report a conflict and leave you to sort it out.
'git pull' == 'git fetch' followed by 'git merge'
so the fetch will always happen, but the merge may not.
As an aside, the local Git folder doesn't seem to be remembered and always defaults to the current project's folder.
I've had troubles in the past with git 'dirs' that were symlinks, but nothing recently. Please could you post/pastebin a sample workspace that does this.

Re: Git plugin - see remote changes

Posted: Sun Apr 23, 2017 1:46 pm
by iwbnwif
git fetch won't change your local files; it only updates git's information about origin
git merge does change local files. If you have uncommitted changes, it will refuse to try. If you have local commits to a relevant file, those changes won't be overwritten; if the merge can't avoid altering your changes to a file, it won't happen; instead it will report a conflict and leave you to sort it out.
'git pull' == 'git fetch' followed by 'git merge'
Sorry to get off topic, but thank you very much for this succinct explanation!

Edit: There is already issue for the folder problem https://github.com/eranif/codelite/issues/1358.