| by Arround The Web | No comments

How to Git Push to a Private Repo?

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:

Step 1: Redirect to Local Repository

First, enter the below-listed command and switch to the desired local repository:

$ cd "C:\Git\demoProject"

 

Step 2: View Repository Content

Then, list the content of the current working repository:

$ ls

 

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:

$ git remote add origin https://github.com/laibayounas/Private_repo.git

 

Step 4: Verify Remote URL

After that, ensure whether the remote URL has been added or not utilizing the following command:

$ git remote -v

 

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:

$ git push origin master

 

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.

Share Button

Source: linuxhint.com

Leave a Reply