How to deal with a private repository

Viewed 39

I need to create a private repository in GitHub so me and my colleagues can write/modify a project in the same time.

I literally spent hours on Google and StackOverflow looking for a clear/simple way to do that but I still can't find anything like that.

Do you have any suggestions please ?

Thank you so much.

2 Answers

If you already have code on your local machine that you'd like to publish on GitHub, do this:

  • In the local folder, start a new git folder by running
    git init
    
  • Go https://github.com/?tab=repositories and click "New" to create a new repo. Don't forget to make it "Private".
  • After you do that, GitHub will tell you how to push local code to your repo. In short, you go to your local folder and do this:
    git remote add origin git@github.com:<yourusername>/<projectname>.git
    git branch -M main
    git push -u origin main
    

Then you should be able to go to your GitHub repository pages and check the code posted.

With the repo up and ready, your collaborators can start adding "Pull Requests" in order to allow modifications. For this, it's good practice to create a branch separate from main, say develop, where features can be added. How to do that is probably topic for another question.

When you create a repository on GitHub there's a radio button that allows you to choose if it's public or private. Setting it to private should do the trick:

enter image description here

Related