0

I am new to git and this appears to be basic question. I see pieces of info here and there but none of them seem to address this basic scenario, Please guide.

I need to clone featureBranch1(not master) to featureBranch2 and I want to add remote featureBranch2 and continue to commit to featureBranch2. I tried

git checkout featureBranch1

git checkout -b featureBranch2

git push -u origin featureBranch2

Update Turned out that above instructions were not working for me as I did not have to repo. Once I was granted access, I could push my changes.

Thanks

BeHappy
  • 138
  • 2
  • 17
  • Possible duplicate of [fatal: The current branch master has no upstream branch](https://stackoverflow.com/questions/23401652/fatal-the-current-branch-master-has-no-upstream-branch) – Peska May 02 '19 at 19:49
  • Possible duplicate of [How do you create a remote Git branch?](https://stackoverflow.com/questions/1519006/how-do-you-create-a-remote-git-branch) – Vlad274 May 02 '19 at 19:49

1 Answers1

0

To create a local branch and the push it to the remote you should use the following commands:

git checkout featureBranch1 // Switch to Feature 1
git checkout -b featureBranch2 // Create Feature 2 as a copy of Feature 1
git push -u origin featureBranch2 // Create a branch Feature 2 on the remote "origin",
                                  // and set (local) Feature 2 to track (remote) Feature 2
Vlad274
  • 6,514
  • 2
  • 32
  • 44
  • This gives me error as remote: You are not allowed to push code to this project. URL tells me that it is pushing to Master, not me featureBranch2 – BeHappy May 02 '19 at 20:11
  • @BeHappy Can you update your question with the exact command you're running and the exact error message you're receiving? – Vlad274 May 02 '19 at 20:14
  • Updated my question @Vlad274 – BeHappy May 02 '19 at 20:16