Is it possible to view version changes locally without pushing to a remote repository? If so, how?

  • 7
    I recommend to get acquainted with GitBook - the step-by-step Russian-speaking guide to git. - ߊߚ߀ߘ
  • one
    @Arhad it is called "Pro Git", and GitBook is something completely different :) - D-side

4 answers 4

Commit history:

# Π² Ρ‚Π΅ΠΊΡƒΡ‰Π΅ΠΉ Π²Π΅Ρ‚ΠΊΠ΅ git log # Если Ρ…ΠΎΡ‚ΠΈΡ‚Π΅ ΠΏΠΎΡΠΌΠΎΡ‚Ρ€Π΅Ρ‚ΡŒ измСнСния Π²ΠΎ всСх Π²Π΅Ρ‚ΠΊΠ°Ρ… Π² красивом Π²ΠΈΠ΄Π΅: git log --oneline --graph --decorate --all 

What has changed in the project files between two commits, branches, tags:

 # явно сравниваСм Π΄Π²Π΅ Π²Π΅Ρ‚ΠΊΠΈ git diff master branch1 # ΠΈΠ»ΠΈ Π΄Π²Π° ΠΊΠΎΠΌΠΌΠΈΡ‚Π° git diff ad72b3 134gf6 # ΠΌΠΎΠΆΠ½ΠΎ ΡΡ€Π°Π²Π½ΠΈΡ‚ΡŒ Ρ‡Ρ‚ΠΎ-Ρ‚ΠΎ с Ρ‚Π΅ΠΊΡƒΡ‰ΠΈΠΌ ΠΊΠΎΠΌΠΌΠΈΡ‚ΠΎΠΌ: git diff branch1 # Π½Π°ΠΏΡ€ΠΈΠΌΠ΅Ρ€, ΡΡ€Π°Π²Π½ΠΈΡ‚ΡŒ ΠΏΡ€Π΅Π΄Ρ‹Π΄ΡƒΡ‰ΠΈΠΉ ΠΊΠΎΠΌΠΌΠΈΡ‚: git diff HEAD^ 

What files have changed since the last commit:

 git status -s 

What has changed in these files since the last commit:

 git diff # ΠΌΠΎΠΆΠ½ΠΎ ΡƒΠΊΠ°Π·Π°Ρ‚ΡŒ ΠΊΠΎΠ½ΠΊΡ€Π΅Ρ‚Π½Ρ‹ΠΉ Ρ„Π°ΠΉΠ»: git diff filename 
  • You can specify a remote branch: git diff origin/master master . This will allow you to see directly the changes that will be flooded after push - vp_arth
  • @vp_arth yes, if you look after the fetch . ) - Nick Volynkin ♦

Good day!

 git status 

Shows the current status (changes in the index, changes not in the index, how many commits you have not made).

 git log 

Displays a list of commits for the branch in which you are located. (There will be commit numbers, their names, author, commit date, etc.)

 git branch 

Will show you which branches you have in the repository and which one you are now

 git diff <Π½Π°Π·Π²Π°Π½ΠΈΠ΅ Ρ„Π°ΠΉΠ»Π°> 

Shows unindexed file changes.

I think, for starters, you will be enough)

  • And how exactly to change the code? For example, it was before commit-public String MyWord () {String word = "HELLO"; return word;} and after-public String MyWord () {String word = "HELLO2"; return word;} - precisely the flashing or hint that this and that has changed! - GoodRA
  • between two commits - GoodRA

The git log -p command in bash directly highlights the red and green changes.

  • 3
    Essentially the same git diff - vp_arth

There are already a lot of answers, but I'll add it myself. View commits with a list of changed files:

 git log --stat 

Sometimes you need to see which commits belong to the current branch. In the gita, this obviously cannot be done, but can be compared with the current branch.

 git cherry -v master 

What changes have been made in the commit can also be seen this way:

 git show 99452d955bdb57e7e4f2b09f8ce2fbb6cd56377a 
  • git log --stat is good. - Nick Volynkin ♦
  • once he rescued me quite often) - Kostiantyn Okhotnyk