My goal is to get rid of one file in all my commits on github so i did next steps:
I have filtered my branch with this command:
git filter-branch --index-filter 'git rm --cached --ignore-unmatch [file_name]' HEAD
ubuntu@ubuntu:/var/www/html/laravel/app_folder$ git status
On branch master
Your branch and 'origin/master' have diverged,
and have 18 and 18 different commits each, respectively.
(use "git pull" to merge the remote branch into yours)
nothing to commit, working directory clean
Yes, you should push... probably.
git filter-branch rewrites history... except it doesn't rewrite it, it creates a new history.
To explain, if your repository looked like this, with the
master branch on commit E as well as origin.
A -- B -- C -- D -- E [master] [origin/master]
Then after you ran
git filter-branch those commits will have been rewritten into new commits. But the origin (on Github) will still be the same.
A -- B -- C -- D -- E [origin/master] \ -- B1 - C1 - D1 - E1 [master]
They have "diverged". This is what
git status is telling you. Your
master is not a child of
Usually this means that you've made local changes to
master while other people have pushed changes to origin's
master. So it's telling you to pull other people's changes.
But this is incorrect. You're overwriting history. So you should
git push your new version of
master. Except git won't allow you to do that for safety reasons, so you have to
git push --force.