How do my collaborators find their way in my industry?

I am new to Git and still found out about this. I want my local branch to commit to remote. I have

  • created a local branch Task1004

    and did some work,
  • made all the changes
  • run get fetch

    andgit pull origin development

  • run git rebase development

    .

Now I want to push my changes, but when I use git log

I see all the other commits that were pushed by other developers on the branch development

; for example one of my own commits and 3 commits by my collaborators.

When I ran

git push origin Task1004

      

all 4 commits are placed in Task1004

, which will later be merged with development

.

What is the reason for this and what should I do to only push my commits?

+3


source to share


1 answer


This is because you folded Task1004

on development

. If you redirect a branch Task1004

to development

(or merge it with development

), your commits will become part of your branch history; there is no way around this (see my detailed explanation below). If you don't want this to happen, just don't reinstall or merge with development

.

On the other hand, why not? It is good practice to be aware of a remote branch that is more stable than the one you are currently working on.


Here is a reconstruction of what happened. I'll refer to the branch as development

"dev" for short. Let's assume at the beginning your repo history looked like this:

A [HEAD,dev,origin/dev]

      

After creating and checking out a branch named, Task1004

you got

A [HEAD,Task1004,dev,origin/dev]

      

After you've done some work, arranged the changes, and committed, your repo history looked like this:



A [dev,origin/dev]
 \ 
  B [HEAD,Task1004]

      

Then you checked out (fetch + merge) the branch dev

that your collaborators have made a few more commits on in that time. Then your repo looked something like this:

A -- C -- D -- E [dev,origin/dev]
 \ 
  B [HEAD,Task1004]

      

Then you folded Task1004

on dev

and ended up with

A -- C -- D -- E [dev,origin/dev]
                \ 
                 B' [HEAD,Task1004]

      

So, because of this, git rebase

your collaborators' commits (C, D and E) became part of the branch Task1004

. Hence, it is normal for these commits to appear in the log of that branch.

To finish, you pushed the branch Task1004

to remote and ended up with

A -- C -- D -- E [dev,origin/dev]
                \ 
                 B' [HEAD,Task1004,origin/Task1004]

      

+3


source







All Articles