How to restore same database when switching branch?

Problem :

I have a question regarding the version control and database. My problem is that I have a branch 'b1' that is stable, now I have created another branch 'b2' and worked for couple of days. Now after few days I am to switching to my previous 'b1' branch.

But my problem is Mysql database still having same database as 'b2' branch. But I want to have the same database when I left with branch 'b1', only those table and those data.

How to achieve this?

Solution :

To do this automatically, you would need to put all database files under version control. Additionally, since the database server doesn't expect those files to change without its knowledge, you would need to restart the server when switching branches. Of course, if the database is being written to, you would also need to commit the changes (in git) after every modification.

If you need this kind of functionality, consider switching to a server-less database that is more suited for this kind of operation. For example, SQLite has no separate server process and holds all database contents in a single file.

Mysql Tutorials

Mysql Howto..

MySQL How to count multiple entries while maintaining unique fileds

how to multiple insert and delete using foreach

how to get values from mysql using php?

How to use timespan in PHP?

How Do You Normalize Text to be Searched in a MySQL Database?

how to make countdown timer to not reset on page refresh

How to optimize this mysql query?

How would you create a clothing size db structure?

MySQL nested queries how to select more than one row

How can I optimise my MySQL query?

How to store multiple language data in database (MySQL)?

How to retrieve utf-8 data with php and show the correct encoding in an excelsheet db dump?

How to create a custom JSON layout from MySQL in PHP

How “perfect” does a database have to be?

How to display MySQL Select statement results in PHP

How to prevent mysql implicit commit

How do NoSql type solutions support consistency when distributed?

How to sort with specific order in mysql query?

How to Stop Row Returning Twice MYSQL

How to change 0 value to '-' in mysql

How to add one year and two days to a date in mysql

How to fetch column names from 'MySQL Create Table' Query string?

how to join two tables on common attributes in mysql and php?

how to make a unique string using php and mysql records before inserting it, and maintain if generated once then do not generate

MySQL: show strings in result that were not found

how to use a specific UPDATE query if existing row is empty mysql

How to/ Where to delete/edit an index from MySql which prevents duplicates row

how to set up daily php functions or mysql queries

how to migrate all of the wordpress content from one host to another?

How to have a range in a MySQL If statement?