Add Existing Project Directory to Git (Github)

Feb 3, 2019

Create a Github repo.

NOTE: For a more straighforward setup, don't create .gitignore or

In the local project directory.

git init

Add remote

git remote add origin [email protected]:USERNAME/PROJECT.git

If you created .gitignore or 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


❤️ Is this article helpful?

Buy me a coffee ☕ or support my work via PayPal to keep this space 🖖 and ad-free.

Do send some 💖 to @d_luaz or share this article.

✨ By Desmond Lua

A dream boy who enjoys making apps, travelling and making youtube videos. Follow me on @d_luaz

👶 Apps I built

Travelopy - discover travel places in Malaysia, Singapore, Taiwan, Japan.