I need to create a branch from another branch with its latest changes. I use bitbucket, I created via website panel and I checked out to the new branch in my VS code but I realized that the latest changes don't come. (suppose there is a branch called A
which created from the development
branch and the A
branch has a bunch of commits and now I need branch B
from A
with its commits) and it seems I create my new branch B from the A but without commits. how can I bring changes in branch B?
Asked
Active
Viewed 101 times
-1

Maik Lowrey
- 15,957
- 6
- 40
- 79

EshgheCode
- 288
- 4
- 19
-
Incoherent. A branch doesn't have "commits". A branch is the name of _one_ commit. All other commits either are or are not _reachable_ from that one commit (by way of the parent chain). Now pose your question in the light of those facts. What's the problem? – matt Nov 13 '21 at 16:03
-
@matt in the A branch I did several changes and I did several commit for that changes. today I create new branch from A. I need those changes to come to B. obvious – EshgheCode Nov 13 '21 at 16:09
-
If you create B from A, the commits you created while on A _are_ "on" B. Again I ask, in terms of what Git really is, what's the problem? – matt Nov 13 '21 at 16:16
-
Perhaps you are having Regret Type 3? https://stackoverflow.com/questions/3528245/whats-the-difference-between-git-reset-mixed-soft-and-hard – matt Nov 13 '21 at 16:23
-
@matt Problem is the commits I created while on A are NOT "on" B. – EshgheCode Nov 13 '21 at 16:24
-
Yes they are. If you `git log B` you will see them listed. Therefore they are "on" B in the only meaningful sense. – matt Nov 13 '21 at 16:46
-
2If you are on A (`git switch A`) and you create B (`git switch -c B`), then all the commits "on" A are now also "on" B. That's just a fact. If you have a supposed counterfact, then you are not doing what I just said. But you have not shown what you _are_ doing; you are just waving your hands. Show what you have done and what is not satisfactory about what `git log B` tells you. – matt Nov 13 '21 at 16:57
-
1Have you made the commits locally, not pushed them, and then created the branch in the BitBucket web UI from an old state of your branch? – knittl Nov 13 '21 at 20:16
1 Answers
0
You can use this command in branch A
:
git checkout -b B A
This way you have branch B
with all A
commit.

Zahra Mirzaei
- 729
- 3
- 7