Reputation: 3235
I have 3 branches (branchone, branchtwo & branchthree) apart from the master branch in my bitbucket repository called "test".
I cloned the repo on my local Windows and got the README.md file.
I then created Jenkinsfile did add, commit & push. I can see the Jenkins file on bitbucket master branch.
I then switched to branchone using "git checkout branchone" and verified the same using git branch command
F:\Jenkins\MultiBranch\test>git branch
* branchone
master
branchtwo
branchthree
I confirmed I had Jenkinsfile and then "git add ." or "git add Jenkinsfile" but git status shows nothing is staged
F:\Jenkins\MultiBranch\test>git status
On branch branchone Your branch is up to date with 'origin/branchone'.
nothing to commit, working tree clean
Below are my questions:
Upvotes: 1
Views: 362
Reputation: 1719
1.When you added your jenkins file to master, committed it and checked out branchone, the jenkins file would not have been there as you already have committed it to master.
Hence, even if you do git add .
, there won't be anything to add in branchone. If you specifically create jenkins file again in your branch one, then you will be able to add it to branchone and commit.
2.I'm not sure how you can simultaneously apply changes to multiple branches in one go. However, You can do so individually for each branch in following ways :
3.There is no concept of sub branches in git. You just have a branch. Branch is just a pointer to a commit. When you say you have branchone, branchone is pointer to commit with #abc123. This commit may have its own tree of commits before it.
When you delete a branch, the pointer to the commit is deleted and not the commit itself. Now, coming back to your question, you can create any number of branches starting from a branch. You can use the command git checkout -b newBranchName
.
If you create a new branch from branchone, Both branchone and newbranch will point to the same commit earlier pointed by branchone. If you add another commit in new branch, only newbranch pointer will move up to point to the latest commit and branchone pointer will stay at the original commit.
Hope this helps.
Upvotes: 1