-2

What are the differences between git push and git commit ? If I want to merge code to my local branch and have not committed and pushed my code; does git merge work in that case?

Aadi
  • 152
  • 15
  • Will this become clear when you read the docs: [GIT commit](https://git-scm.com/docs/git-commit), [GIT push](https://git-scm.com/docs/git-push) ? – Luuk Sep 04 '21 at 09:21
  • @Luuk I don't think that _Update remote refs along with associated objects_ will tell much to anyone who asks this kind of question. – bereal Sep 04 '21 at 09:23
  • 1
    There is a link to the [book](https://git-scm.com/book/en/v2) which should give more info on this matter, on both of the links I provided, and there are [videos](https://git-scm.com/videos) too. Some insight in what the question asker did to try and find out details about this question are missing... (We cannot/shouldnot copy the book here) – Luuk Sep 04 '21 at 09:28

3 Answers3

2

git commit is more like saving your changes in the repo you are working on. while you commit you gotta give a commit message that describes the changes you are commiting.

git push is updating the remote repo with the new commits(saved changes) in the local repo. remote repo is the repo that is hosted on the internet and local repo is the repo you are working on in your computer. when u git push from ur local repo, the commits (if any) in it will be brought into the remote repo.

1

git commit will commit your changes into your local git repo. git push will update your remote repo with your local repo.

Poorna
  • 72
  • 8
1

They are completely different. The first is used to interact with a remote repository, while the latter is used for your local repository. More precisely:

  1. git push sync the local repository with its associated remote repository and updates it
  2. git commit only records changes to the local repository
Giuseppe Amato
  • 103
  • 1
  • 1
  • 7