Create a Github repo.
NOTE: For a more straighforward setup, don't create .gitignore
or README.md
.
In the local project directory.
git init
Add remote
git remote add origin [email protected]:USERNAME/PROJECT.git
If you created .gitignore
or README.md
when creating github repo, you need to run the following command to pull these files from remote to local.
git pull origin master
Check the current git status (it will show files not tracked by git yet).
git status
If you want to filter certain files from git (e.g. tmp folder, compiled files, password or secret file, etc.), you want want a .gitignore
(assuming you didn't create those during Github repo creation). Refer to Exclude/Ignore File or Directory From Git (.gitignore).
You can check files ignored by git.
git status --ignored
One you are satiesfied with git status
and .gitignore
setup, run the following command to include existing files to be tracked by git.
git add .
Commit with message
git commit -m 'first commit'
NOTE: Git Add vs Commit
Push local git to remote.
git push origin master
References: