DEV Community

Mehak Saini
Mehak Saini

Posted on

#4 Adding existing project to git repo

  1. Create a new Repo from the UI
  2. Navigate to current project directory from terminal and run the below commands.

Initializes the local directory as a git repo

git init -b main
Enter fullscreen mode Exit fullscreen mode

Add the url for the remote repo where the local repo will be pushed

git remote add origin git@github.com:<github-url>
Enter fullscreen mode Exit fullscreen mode

Pull changes from remote repo to local(.gitignore, READMe.md)

git pull origin main
Enter fullscreen mode Exit fullscreen mode

*Add the files to be committed *

git add .
Enter fullscreen mode Exit fullscreen mode

Commit

git commit -m "Initial commit"
Enter fullscreen mode Exit fullscreen mode

Push the changes to remote

git push origin main
Enter fullscreen mode Exit fullscreen mode

Top comments (0)