- Create a new repository on GitHub. You can also add a gitignore file, a readme and a > licence if you want
- Open Git Bash
- Change the current working directory to your local project.
- Initialize the local directory as a Git repository.1git initCopied!
- Add the files in your new local repository. This stages them for the first commit.1git add .Copied!
- Commit the files that you’ve staged in your local repository.1git commit -m "initial commit"Copied!
- Copy the https url of your newly created repo
- In the Command prompt, add the URL for the remote repository where your local repository > will be pushed.1git remote add origin 'remote_repository_URL'Copied!1git remote -vCopied!
- Push the changes in your local repository to GitHub.1git push -f origin masterCopied!
.gitfolder may cause problems in your git repository. If you want to delete all your commit history but keep the code in its current state, it is very safe to do it as in the following:
git checkout --orphan latest_branch
git add -A
git commit -am "commit message"
git branch -D main
git branch -m main
git push -f origin main