Suppose I have a repository on my local machine, a working directory where I make changes and push to remotes, and I decide I would like to add a new feature which will in time replace an in place feature.
What happens when I create a new branch and start modifying my working directory? If I switch to the new branch and start making changes, those changes are overwriting code on my local machine, are they not?
So if I have two branches, one Master and one NewFeature, how can I maintain copies of both on my local machine up until I decide merging is ready?
How is this normally done?
You have a folder on the repo with the name .git, this folder contains all the information that is necessary for your project in version control and all the information about commits, remote repository address etc. all are present in this folder. It also contains a log which stores your commit history so that you can roll back to history.
When you working on Master branch, on your local folder you have the files of the Master branch.
When you run the command git checkout NewFeature and in this branch have any changes from Master branch, you local folder will be overwriting the Master with NewFeature changes.
But you do not lose your Master branch content, it saves on .git folder, when you will go back to the Master your local folder will be changed again.
So - you don't have yo maintain your 2 branches, GIT does it for you.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With