-1

I have two branches: main and develop/selenium.

We on the test team want to work on develop/selenium so we would like to create new branches from it. Now I understand how to do that with git checkout -b "branch-name" develop/selenium.

The part where I get confused is when it comes to pushing this commit, for example when I write a test and go to commit it, I would do git commit -m "something"

But then would I do (to push the local feature branch I'm working on to remote develop/selenium) git push origin branch-name

And then to (push remote develop/selenium to remote main)

Is that how it would work or have I misunderstood?

In work we have been asked to clone develop/selenium and create branches on it, but I didn't think we could clone just the branch, would the main not just be cloned and we would still have to checkout develop/selenium and work from there right?

Prophet
  • 32,350
  • 22
  • 54
  • 79
Darragh.H
  • 3
  • 6
  • 1
    Does this answer your question? [How do I push a new local branch to a remote Git repository and track it too?](https://stackoverflow.com/questions/2765421/how-do-i-push-a-new-local-branch-to-a-remote-git-repository-and-track-it-too) – Joe May 20 '21 at 10:58
  • no Joe, the question is if I create a sub branch off develop/selenium where does it need to be pushed – Darragh.H May 20 '21 at 13:29
  • There is no such thing as a "sub-branch". Branch names have no parent/child relationship to other branch names. The only things that really matter are the commits themselves, which *do* have parent/child relationships to other commits. Moreover, branch names in *your* Git repository need not correspond to branch names in some *other* Git repository. The things that matter—in both repositories—are still just the *commits themselves*. The other Git repository will use its own branch names to help it find commits. – torek May 20 '21 at 21:01

1 Answers1

1

According to what you have described you should do the following:
In case there are no multiple people working on develop_selenium, when you wish to commit and push your local changes to the remote develop_selenium branch you will have to do the following:
When inside the local develop_selenium branch

git add *

to add the changed files to be committed.
Then you should

git commit -am "what we have done here comment"

to commit the local changes.
And then

git push origin develop_selenium

to push it into remote develop_selenium branch.
Now you should switch to master branch on your local repository using

git checkout master

Now you should update local master with remote master using

git pull origin master

Now, when you still in your local master branch, you should merge local develop_selenium into local master using

git merge develop_selenium

This may give you conflicts which need to be resolved and changes committed before moving further.
Once merge of develop_selenium to master on local is committed, push local master to remote master using

git push origin master
Prophet
  • 32,350
  • 22
  • 54
  • 79