Search code examples
gitphpstorm

Make current state as starting point for Git in PhpStorm


I have a project in PhpStorm. When it comes to Git, I am new to it. Previously I made some test commits and pushed them into GitLab. I would like to have my current code/state in PhpStorm to be as a starting point.

How do I remove previous commits from PhpStorm and GitLab and have a clean start?


Solution

  • If you do not care about you previous commits, you can delete the .git directory and then git init a new repository in your project root. Add all files and then force-push to GitLab, overwriting all other commits. WARNING: You will lose all previous commits forever.

    If, however, you might still need the old commits, you can create a new fully disconnected branch with git checkout --orphan new_branch_name and then committing the current state.