Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference between git diff (git patch) and git push

Tags:

git

git push is used to push changes to a remote repository. git diff shows the all the changes made since the last pull operation from the remote repository. git diff is synonymously used as git patch. After getting the difference, the patch is applied through git am or git apply to another repository for updation.

So, are these two commands fundamentally same or is there any difference between git diff and git push?

like image 826
RAM Avatar asked Feb 23 '26 03:02

RAM


2 Answers

First of all

$ git patch
git: 'patch' is not a git command. See 'git --help'.

Now as far as git diff versus git push

NAME
       git-diff

DESCRIPTION
       Show changes between the working tree and the index or a tree, changes
       between the index and a tree, changes between two trees, or changes
       between two files on disk.
NAME
       git-push

DESCRIPTION
       Updates remote refs using local refs, while sending objects necessary
       to complete the given refs.
like image 191
Zombo Avatar answered Feb 25 '26 21:02

Zombo


git push is to push all the changes you made in the file to the repository. this is the last step you make to add a change into your project.

Git diff is used to see all the changes made into the different files since the last commit. it shows all the line added or removed into the project.

The basic flow goes like this.

you make some changes in the project. -> you do git add -> do git diff if you want to see what changes have been made -> you commit using git commit -> push the committed changes into the repository using git push.

If you are new to git, learn this interactive tutorial http://try.github.com/

like image 40
user1263375 Avatar answered Feb 25 '26 20:02

user1263375