Git Common Tasks
Add Remote for Existing Project
Initialize the local directory as a Git repository.
$ git init
Create a .gitignore
file in the root directory of the project.
Add the files in your new local repository. This stages them for the first commit.
$ git add .
Commit the files that you’ve staged in your local repository.
$ git commit -m 'First commit'
Add the URL for the remote repository where your local repository will be pushed.
$ git remote add origin [remote repository URL]
Verify remote repository
$ git remote -v
Push the changes in your local repository to GitHub.
$ git push origin master
Remove the Latest Commit before Push
$ git reset --soft HEAD~1
Force Pull & Overwrite Local Repository
$ git fetch --all
$ git reset --hard origin/master
Force Push & Overwrite Remote Repository
$ git push [remote] [branch] -f
$ git push origin master -f # Example