Git adventures
I wanted to clean up some Bootstrap files from a project directory. After the cleanup. I pushed the changes to the remote repo (BitBucket).
However, I noticed that the files that should be deleted (and was deleted on local repo), was still existing on the remote repo.
After some head scratching, i released that the problem was that I used the file system delete, instead of the git delete.
$ git rm $ git add . $ git commit -m "changes" $ git push
Everything was fine now and good, until I come back to see that i deleted an important directory due to a misuse of the “*” during the delete.
Well, that what and DSCM was meant for.. Git come to the rescue…. except that it took me 30mins or trying different command ( and help from Stackoverflow) to find the right combo, thus:
cf361cb is the last commit with the missing directory
$ git revert --no-commit cf361cb..HEAD $ git commit
This is a safe and easy way to rollback to a previous state. Checks for the missing directory
$ ls -ltr $ cd static/
Cleanup files
$ git rm *.css $ git rm *.js
Then commit and push
$ git add . $ git status $ 1398 git commit -m "UI file cleanup" $ git push
And Wossah!!
The git throws up a new error, “fatal: You are not currently on a branch”
I checked on the git
$ git status
And trully, you are not a branch!
I was getting loosing the modification twice after using 2 different command, until i hit on the right combo (also good help from stackoverflow)
$ git checkout -b newbranch $ git checkout master $ git merge newbranch $ git branch -d newbranch $ git status $ git push
Hurray!!