While working on Git, developers work on their local system. After completing their work locally, they push their work to the remote repository. However, the remote repository can be public or private. More specifically, GitHub allows users to create and save their work to any public or private repository.
This study will explain the procedure to Git push to a private repository.
How to Git Push to a Private Repository?
To push to a private repository, follow the below-provided steps:
- Switch to the local repository.
- View local repository content.
- Add a remote URL and verify it.
- Push local changes to the private remote repository using the “git push origin master” command.
- Verify changes in the remote repository.
Step 1: Redirect to Local Repository
First, enter the below-listed command and switch to the desired local repository:
Step 2: View Repository Content
Then, list the content of the current working repository:
Step 3: Add Remote URL
Now, utilize the given command along with the private remote repository’s URL and link the local repository with it:
Step 4: Verify Remote URL
After that, ensure whether the remote URL has been added or not utilizing the following command:
It can be seen that the remote URL has been added successfully:
Step 5: Push to Private Repository
Finally, execute the following command to push the content of the local repository to the private remote repository:
The below output indicates that the local changes have been pushed to the remote repository:
Step 6: Verify Changes on Remote Repository
To verify whether the changes have been pushed to the private repository or not, open the GitHub, navigate to the desired private repository and view changes:
In the above screenshot, the local repository’s content can be seen in the private remote repository.
Conclusion
To push to a private repository, first, navigate to the local repository and view its content. Then, add the remote URL to connect the local repository with the private remote repository. Next, execute the “git push origin master” command to push changes to the private repository. Lastly, verify changes in the remote repository. This study explained the procedure to Git push to a private repository.