-1

I have a remote repository in mainline branch. I want to add a private branch that gives access to me and my friend alone. How to commit and push the code in that private branch. Can you please help me with the git commands to do the following tasks. I am using a windows OS.

 1. create a private branch
 2. add a friend to the branch 
 3. commit and push the code to the branch

This is the branch which I am in. I need to push the project repository in the private branch created.

C:\Users\MyProject>git branch
* mainline
TTT
  • 22,611
  • 8
  • 63
  • 69
AKSHAYA V
  • 23
  • 3
  • Can you explain the hard part? You create and switch to the branch and push it. What do you _not_ know? – matt Jun 25 '20 at 15:54
  • I am a beginner using git . I just want to know the commands to do this – AKSHAYA V Jun 25 '20 at 16:01
  • "I am a beginner using git . I just want to know the commands to do this" But you're not willing to do any actual work / research of your own? That sort of thing is important on Stack Overflow. A beginner at git is not a beginner at thinking, searching, etc. – matt Jun 25 '20 at 16:37
  • I rolled back to the original version of the question, which already has a valid answer. The edit makes a completely different (and very basic) question. Note both are also duplicates. Here's the dup for the current version of the question: https://stackoverflow.com/q/7983204/184546 – TTT Jun 25 '20 at 16:38
  • @TTT Problem is that the whole question-and-answer is now living a lie. It purports to ask and answer about the private branch, but in fact the OP just wanted the basic branch and push commands given in the answer's comments. – matt Jun 25 '20 at 16:39
  • @matt - the original (what I rolled back to) now matches the answer. I don't care (as much) that the user just wanted to know how to create a branch, and that is answered in the comments. :) – TTT Jun 25 '20 at 16:41
  • @matt - I think what happened was this: How can I do A? You can't do A. Oh. How can I do B? Like this. Since the answer is accepted already for A, we can't just leave it when the question is changed to ask about B... (Though, maybe we could just delete the entire question and answer... hehe.) – TTT Jun 25 '20 at 16:43

1 Answers1

1

There is no concept of a private branch on a public repo.... you can have a private branch on a local repo, say (cause no one else will be able to access it unless you set the repo for access).... what you can do is clone that public repo and into a different private repo and then provide access to that repo to your friends.

eftshift0
  • 26,375
  • 3
  • 36
  • 60
  • ohh then can you just give me the commands to do everything in another branch instead of main branch ? – AKSHAYA V Jun 25 '20 at 15:40
  • In order to create a new branch and switch to it in a single shot: `git checkout -b new-branch`. That will create a new _local_ branch called `new-branch`. But this is a completely different question. – eftshift0 Jun 25 '20 at 15:43