Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Multiple commits before pushing

Tags:

git

I'm completely new to GIT, so excuse the naivety. If I'm working on a project offline, and I do multiple commits then push the changes once I'm back online, will all the commits show up in my repository, or just the last one I did before going back online?

like image 829
bjork24 Avatar asked Feb 28 '11 15:02

bjork24


People also ask

Can we do multiple commits before pushing?

Committing takes place only within your repository; it has nothing to do with whether or not you're online. The things that you need to be online for are pushing (publishing your commits to another repository) and pulling (fetching and merging commits from another repository).

Should I push after every commit?

Typically pushing and pulling a few times a day is sufficient. Like @earlonrails said, more frequent pushes means less likelihood of conflicting changes but typically it isn't that big a deal. Think of it this way, by committing to your local repository you are basically saying "I trust this code. It is complete.

Does git push push multiple commits?

No, git push only pushes commits from current local branch to remote branch that you specified in command.

Which comes first push or commit?

Basics. – Pushing comes after committing. Git commit records and tracks changes to the repository with each commit points to a tree object that captures the state of the repository at that moment the commit was performed, all in one complete snapshot.


2 Answers

Git is a distributed version control system. Your repository is entirely your own, and it contains absolutely everything you need. Committing takes place only within your repository; it has nothing to do with whether or not you're online.

The things that you need to be online for are pushing (publishing your commits to another repository) and pulling (fetching and merging commits from another repository). When you push, it will push exactly what you told it to - all of the commits on that branch. It doesn't matter when you made them or if your network cable was plugged in at the time.

like image 94
Cascabel Avatar answered Sep 20 '22 01:09

Cascabel


All your commits will be pushed.

like image 24
krtek Avatar answered Sep 24 '22 01:09

krtek