When you’re testing but your develop branch seems off between master branch
I had some weird thing working with git. While I was testing, my master branch seems to be off from the develop branch.
I tested and development branch seems to be good state. When I checkout back to master branch, nothing seems to work how it suppose to. Why is this? I just can't check all files each and compare with the working ones?
Suddenly I got genius idea. How about saving the best current state then go back to master branch and copy from the Save State? I don't mean about Git stash. About zipping the directory while excluding .git
directory and node_modules
from the develop
good state branch, then set to master
branch and extract it. Then check with git status and commit changes. Boom! master
is in sync with develop
.
I don’t know why git do this, but perhaps I was running old version on my Mac. It was git version 2.4.9. And now it suppose to be 2.7.0.
Time for upgrade that is.
How did you fix your problem?
Let's say I show you the path of my git repository directory.
/data/my/git/myproject
.
And my git is inside that directory, like so:
/data/my/git/myproject/.git
First I go the branch that seems the best files and best state, for me it's develop
.
git checkout develop
I can with confidence make an exact clone for this with: tar
So I go to my sub directory
/data/my/git
And I do the compressing with tar
tar -cvzpf develop-branch.tar.gz --exclude='myproject/.git' --exclude='myproject/node_modules' myproject
See I use
--exclude
to exclude.git
directory. This is very important.
You just make a Save Point! YEAH!
then head to:
/data/my/git/myproject
and set to weird branch; master
git checkout master
and go back to the sub directory
/data/my/git
Extract the tar.gz
file.
tar -xvzpf develop-branch.tar.gz
and go back to your project directory:
/data/my/git/myproject
and check your status
git status
BAM.. weird changes that should be there!
Add the files and Commit it and call it a day!
git add .
git commit -avm "Everything is in sync!!!"
And now back to sleep!