Skip to content

Instantly share code, notes, and snippets.

@amberj
Last active May 14, 2024 18:39
Show Gist options
  • Save amberj/f53038e9a1adfb5d7d82bb594e19877a to your computer and use it in GitHub Desktop.
Save amberj/f53038e9a1adfb5d7d82bb594e19877a to your computer and use it in GitHub Desktop.
Create git repo within existing project folder and push it to github

Initialize the local directory as a Git repository.

git init

Add the files in your new local repository. This stages them for the first commit.

git add .

Optional step: Configure your name and email id in git

The following command will open git config file in terminal editor (vim or nano)

git config --global --edit

Commit the files that you've staged in your local repository.

git commit -m 'First project import'

Add the URL for the remote repository where your local repostory will be pushed.

Replace <PROJECT_NAME> with name of project on Github.

git remote add origin https://github.com/amberj/<PROJECT_NAME>.git

Sets the new remote:

git remote -v

Push the changes in your local repository to GitHub.

git push -u origin main
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment