Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

When you use git commits on local computer do you lose branches/commits when you turn off the computer?

Probably a simple question but when you are using git locally on your computer do you lose branches and commits when the computer is turned off?

like image 877
Jonathan Pitcher Avatar asked Oct 27 '25 14:10

Jonathan Pitcher


1 Answers

No. When a repo is initialized with git, all local changes and branches are saved in the git working directory. This is somewhat same as saving a file in your computer. Hence, local changes will not but losed.

A commit is just a snapshot of the contents of the repository. When you give commit, git computes a hash value over the contents of the repository and saves the state of the repository. Here is a good reference on recording changes to git repository.

like image 193
arunppsg Avatar answered Oct 29 '25 04:10

arunppsg



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!