Search code examples
gitgit-remote

How to add remote Git repo to local repo and keep it updated?


I have authorization by public_key to remote repo and I can get everything from http://someurl/first.git on my local machine, but I have to populate this changes to other environments. To make it possible I have to put there my private_key, clone repo and switch to specified tag. But I don't want to do it because of security reasons.

I'm thinking about creation of my local repo http://someurl/second.git, committing all changes to it and deploy. But I have now idea how to add remote repo to my local? Is it possible? And how to commit to my local repo from remote and switch to needed tag?


Solution

  • Noufal Ibrahim should post his comment as an answer :

    Use git remote add to register a new remote repository, e.g. :

    git remote add site2 http://someurl/second.git
    

    After that, you can push from your local machine to this other repository :

    git push site2 myBranch