Can I see from the local workplace:

  1. Have there been changes to the remote repository
  2. What were the changes

To make a decision - to pour in, not to pour in and what to pour in?


found a solution to view diff changes after fetch

 git diff HEAD ... origin / master
 git diff HEAD ... origin / branch1

how competent is it?
the conclusion is quite visual

enter image description here

  • one
    you can always do just git fetch and see it locally. It will not merzhitsya. - KoVadim
  • one
    Is simple git log enough? - Sasha Chernykh
  • @KoVadim made a fetch, didn’t fail, but git diff didn’t show anything - there was no output at all in the terminal ... although on a remote repo - the changes were made ... how am I doing wrong? - buyboy
  • one
    as you have already written - git diff master...origin/master and the like - KoVadim

2 answers 2

The git pull command is actually a sequence of two commands: fetch and merge .

fetch - gets updated pointers (i.e., branches - branch, and tags - tag) and downloads all the objects necessary for their (pointers) use (i.e., commits - commit, trees - tree and “blobs” - blob binary large object).

merge pointer - tries to “inject” a commit (and all interval commits) referenced by the pointer into your current branch (the branch in git is a floating pointer to the commit).

doing not pull , but only the first part - fetch :

 $ git fetch 

You will be able to see which commits are now separating your local pointer (for example, the master branch) from another pointer received from the remote repository (if only one is connected to the repository, the default is called origin ), for example, the master branch of the same name, which can be designated as origin/master :

 $ git log master..origin/master 

the two dots here are part of the syntax.

which changes occurred and in which files, you can see by adding the -p option to the log command:

 $ git log -p master..origin/master 

or you can see the complete list of differences in the files between the two pointers:

 $ git diff master..origin/master 

found a solution to view diff changes after fetch
git diff HEAD...origin/master
how competent is it?

fully qualified.

and fully corresponds to the output of git diff master..origin/master , if master is your current branch. You can specify with the help of the git status command, or more “low-level”, by looking into the contents of the .git/HEAD file. example:

 $ cat .git/HEAD ref: refs/heads/master 

here the HEAD pointer refers to the local master branch.

  • cool! Thanks for the detailed answer! - buyboy
  • and how to merge? if I, for example, need to take only one thing - buyboy
  • @buyboy, this is a completely different question, which, as far as I remember, has already met more than once. - aleksandr barakin
  • 2
    @buyboy, since you need git not only for add/commit/push/pull , so as not to ask each time, read the guidelines for its use. This is short, written in understandable language, and in this more material and details. Where it is not clear, stop - go here. - Sasha Chernykh
  • @alexander barakin cool! megascabo! - buyboy

If you understand everything correctly, you need the git log command. If you do not enter any additional parameters, the hash of the commit, its author, date, and description are displayed:

 $ git log commit fa3c1411aa09441695a9e645d4371e8d749da1dc Author: Alexander Shvets <alex@githowto.com> Date: Wed Mar 9 10:27:54 2011 -0500 Added HTML header commit 8c3228730ed03116815a5cc682e8105e7d981928 Author: Alexander Shvets <alex@githowto.com> Date: Wed Mar 9 10:27:54 2011 -0500 Added standard HTML page tags commit 43628f779cb333dd30d78186499f93638107f70b Author: Alexander Shvets <alex@githowto.com> Date: Wed Mar 9 10:27:54 2011 -0500 Added h1 tag commit 911e8c91caeab8d30ad16d56746cbd6eef72dc4c Author: Alexander Shvets <alex@githowto.com> Date: Wed Mar 9 10:27:54 2011 -0500 First Commit 

About the team and the parameters painted here .

If “what were the changes” means the content of the changes, the -p parameter is required to view diffs. You can also specify the number of recent commits whose content we need to view.

In the example below, in addition to the default parameters of the git log command, the difference of changes is output - -p - the last two commits - -2 .

 $ git log -p -2 commit ca82a6dff817ec66f44342007202690a93763949 Author: Scott Chacon <schacon@gee-mail.com> Date: Mon Mar 17 21:52:11 2008 -0700 changed the version number diff --git a/Rakefile b/Rakefile index a874b73..8f94139 100644 --- a/Rakefile +++ b/Rakefile @@ -5,5 +5,5 @@ require 'rake/gempackagetask' spec = Gem::Specification.new do |s| s.name = "simplegit" - s.version = "0.1.0" + s.version = "0.1.1" s.author = "Scott Chacon" s.email = "schacon@gee-mail.com commit 085bb3bcb608e1e8451d4b2432f8ecbe6306e7e7 Author: Scott Chacon <schacon@gee-mail.com> Date: Sat Mar 15 16:40:33 2008 -0700 removed unnecessary test code diff --git a/lib/simplegit.rb b/lib/simplegit.rb index a0a60ae..47c6340 100644 --- a/lib/simplegit.rb +++ b/lib/simplegit.rb @@ -18,8 +18,3 @@ class SimpleGit end end - -if $0 == __FILE__ - git = SimpleGit.new - puts git.show -end \ No newline at end of file 

Details on additional options here .

  • one
    Trump ... first look short, and then display the right one ... big respect for the answer! - buyboy
  • By the way, are these hashes used in git cherry-pick to join? - buyboy
  • one
    @buyboy, yes, see git-scm.com/book/ru/v1/… - Sasha Chernykh
  • @buyboy, if any answer helped in solving your problem, please tick the box next to it. This will show other participants that the issue is resolved, and you will add an additional 2 points of reputation. - Sasha Chernykh
  • OK, I already put it - buyboy