2

Before I pull from a remote repository I would like to size up the changes. Not completely sure what information is available. A list of commits (with descriptions) and a list of files changed is a good place to start.

For anybody familiar with perforce, I want the exact equivant to "p4 sync -n".

I thought this would be easy. I first checked "git help pull". I then checked google. Run out of places to check.

tdprime
  • 21
  • 4
  • 2
    Not sure what “size up the changes“ means exactly, but maybe you’re looking for `git fetch` followed by `git diff HEAD...@{u}`? Or `git pull --dry-run`? – Ry- Oct 31 '21 at 21:11
  • I am not seeing dry-run in "git help pull". – tdprime Nov 10 '21 at 13:58
  • On the surface, git-fetch seems to be way off the mark. Since the meaning isn't clear, where would I find documentation that applies get-fetch to my use case? – tdprime Nov 10 '21 at 14:00
  • What is @{u}? I am not finding that in "git help diff". – tdprime Nov 10 '21 at 14:02
  • @tdprime I have edited my answer to address your comment. – VonC Nov 10 '21 at 16:08
  • The answer to your question is _"**Do not** use `git pull`"_. It is not good for what you need, it is not good for almost anything except creating surprises. Run `git fetch` then use `git log` to find the differences. Or, better, use a Git GUI application to inspect for the changes. – axiac Nov 10 '21 at 16:12

1 Answers1

2

There is no direct equivalence for p4 sync -n in Git.

A list of commits (with descriptions) and a list of files changed is a good place to start.

That would still involve a git fetch first.
Then, as commented:

git diff --name-only @ @{u}
git log --pretty=oneline @{u}..HEAD

As illustrated in "How to compare a local Git branch with its remote branch", @{u} from git revisions

The suffix @{upstream} to a branchname (short form <branchname>@{u}) refers to the branch that the branch specified by branchname is set to build on top of (configured with branch.<name>.remote and branch.<name>.merge).

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250