Here are some git commands I use regularly, but sometimes forget then search them on Google LOL 😆

Add an existing project to an empty Github repository

Use these following commands if you create an empty Github repository without a readme and .gitignore files.

$ git init 
$ git add .
$ git commit -m "Init"
$ git remote add origin https://github.com/<github-username>/<repository-name>.git
$ git push origin master

Add an existing project to a Github repository that contains a README file.

$ git init 
$ git remote add origin https://github.com/<github-username>/<repository-name>.git
$ git pull origin master
$ git add .
$ git commit -m "Init"
$ git push origin master

Merging without commit history

Let’s say you have a branch named b10 that has already had some commits. Now you want to merge it into master but only in one commit.

$ git checkout master
$ git merge --squash b10
$ git commit -m "Merged b10"
$ git push origin master

References