Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to view diff between head of local repository and head of remote repository?

Tags:

mercurial

Before I push to a remote repository, I want to see a consolidated diff between the head of my local repository and the head of the repository I'm pushing too. The best way I know of doing this is to hg clone the remote repository, get the revision of the head, then do a diff between my head and that revision. But this is time-consuming. Is there a quick way?

like image 426
jhourback Avatar asked Jan 14 '12 15:01

jhourback


People also ask

How can you tell the difference between a local and remote repository?

You can git branch -a to list all branches (local and remote) and then choose the branch name from the list (just remove remotes/ from the remote branch name. Example: git diff main origin/main (where "main" is the local main branch and "origin/main" is a remote, namely the origin and main branch.)

How do I tell the difference between local master and remote master?

1 Answer. You can use git branch -a to list all branches then choose the branch name from the list from the remote branch name. Example: git diff master origin/master (where "master" is a local master branch and "origin/master" is a remote namely origin and master branch.)

What is the difference between remote branch and local branch in git?

A local branch is a branch that only you (the local user) can see. It exists only on your local machine. A remote branch is a branch on a remote location (in most cases origin ). You can push the newly created local branch myNewBranch to origin .


2 Answers

In addition to

$ hg outgoing -p

which I normally use, I'll like to point you to revision sets. That is a query language that you can use with hg diff (and all other commands that lets you specify changesets). So you can implement hg outgoing -p by

$ hg log -r "outgoing()" -p

and you can get a diff between the parent of the first outgoing changeset and the last outgoing changeset with

$ hg diff -r "p1(first(outgoing()))" -r "last(outgoing())"

Finally, the remotebranch extension can maintain local information about the remote branches so that you don't need to use the network to lookup this information. It lets you use

$ hg log -r "not pushed()"

to find the outgoing changesets, but it's much faster since there's no network round trips involved.

like image 111
Martin Geisler Avatar answered Sep 25 '22 08:09

Martin Geisler


If you're looking for a way of getting all the changes you've made that aren't in the remote repository.

$ hg outgoing -p

The -p is optional and reports in the form of a patch, otherwise it reports in the same way a hg log. This is just your changes regardless of whether anybody else has pushed anything to the remote repository.

If you're looking for changes in the remote repository that you don't have then you use

$ hg incoming

Again there's a -p form if you want it.


Neither of these are exactly what you asked for, but I suspect you don't actually want that.

If you really want the difference between your changes and the new head in the remote repo created by someone else, then you'll need to pull their changes over.

hg pull
hg heads                     # find revision number of new head 
hg diff -r 124992            # or whatever the revision number is.
like image 28
Paul S Avatar answered Sep 25 '22 08:09

Paul S