dushkin
dushkin

Reputation: 2101

Git: How to understand the 'git branch -a --merged master' listing?

When on master branch I executed the following commands:

git fetch
git branch -a --merged master

I got the following listing:

$ git branch -a --merged master
  branch1
  branch2
* master
  remotes/origin/branch1
  remotes/origin/branch4
  remotes/origin/branch3

Can I understand from this listing that branch1 was merged and pushed to the remote master branch?

I emphasize the main point which interests me: was it also pushed to the master branch?

Upvotes: 0

Views: 627

Answers (1)

padawin
padawin

Reputation: 4476

As context and reminder:

  • Commits in Git are a linked list, every commit contains the hash of their parent(s)
  • Branches are label to specific commits (under the hood, a branch is a file with as name the branch's name and as content the hash of the commit it points to

The command git branch -a --merged master gives you all the branches (local and remote, from the -a option, --all) which are accessible from ("merged in") master (from the --merged master option). That means all the branches which points to commits which are ancestors (parents/grand parents/...) of master.

The term --merged is slightly misleading as it does not necessarily mean that the branches have been merged (with merge commit and so on) in master.

EDIT: From your question in the comments:

I want to know if my local branches were already merged to remote master and pushed to remote repository.

Are your branches merged to remote master:

git branch --merged origin/master # Here do your branches appear?

Are your branches pushed to the remote repository:

git branch -r # Here do your branches appear?
git branch -v # This will show your for each branch if they are ahead, behind or both. This works only if their upstream is set.

For more info: man git-branch.

Upvotes: 1

Related Questions