To connect the local repo to the existing Git Repository and pull down changes

2/18/2024
All Articles

#existing Git Repository #pull down changes #github #repository

To connect the local repo to the existing Git Repository and pull down changes

To connect the local repo to the existing Git Repository and pull down changes

    Open your terminal or command prompt and navigate to the directory where your local repository is located.
Then write below command to terminal and try to complete initialisation of git repository to local first time.

  •     git init -b main.
  •     git remote add origin <REMOTE_URL>
  •     Check if it's setup correctly using git remote -v.
  •     git fetch.
  •     Use git branch command to make sure the "main" branch is created locally.
  •     git checkout main
  •     git add .
  •     git commit -m "first init"
  •     git push -u origin main

 

Conclusion

In this article we learn , how to set up git repo first time.More important point that is replace [branch_name] with the name of the branch you want to pull changes from.
    If you're not sure about the branch name, you can usually use git pull origin master for the default branch (often master or main).

Article