GIT, display of branchs in bitbucket tree

Asked

Viewed 982 times

6

Hello! I’ve been researching for days and I haven’t found any information that helps me.

my problem is with displaying the commits tree and branchs in bitbucket.

I create a branch from the master git checkout -b develop I’ll do the commits and then I’ll go back to the master and do a merge of the develop.

I would like you to have a graph like the example below:

* merged from develop
|\
| * - commit 5
| * - commit 4
| * - commit 3
| * - commit 2
| * - commit 1
|/
* branch master

como eu gostaria

but there’s only one straight line

*
* - commit 5
* - commit 4
* - commit 3
* - commit 2
* - commit 1
* - branch master

como fica

at first I can only do as I’d like to do for the bitbucket itself pull request, but I’d like to do it by command line in git-bash.

Thanks in advance!

  • 3

    you are working directly at master, so you are in a straight line.

3 answers

5

Just do the merge without fast-foward. You can do this with the following command: git merge develop --no-ff. the --no-ff ensures that when merging, a new commit will be generated.

If you want to view the tree on the command line, the same way you view it in Bitbucket, just run this command:

git log --graph --all --oneline --decorate
  • --graph shows in graphic form
  • --all indicates that all branchs
  • --oneline defines that only the first line of the commit will be shown and the abbreviated commit hash
  • --decorate ensures that the names of branchs will appear

To finish, you can still create a alias to facilitate future typing of the command with git config --global alias.graph "log --graph --all --oneline --decorate" and then just run the alias with git graph.

The result of the command is more or less what appears in the image below:

resultado do git log

2

That’s how you work.

In this case, when you work on the same branch (master), it follows a current line.

To work in parallel, you have to create a new branch from the master.

seuprojeto (master): git checkout -bPRO-01-nome-branch-mudanca.

And then start working on the ticket. After you’re done, commit the changes:

your project (PRO-01-name-branch-change): git commit -am"PRO-01 mudanças feitas xyz #resolve".

Then send the branch to the bitbucket:

your project (PRO-01-name-branch-change): git push origin PRO-01-nome-branch-mudanca

Then check out the master, staging or deploy (depends on how it works):

your project (PRO-01-name-branch-change): git checkout master

Bring other updates to your site:

seuprojeto (master):git pull origin master

Merge changes with master:

seuprojeto (master):git merge PRO-01-nome-branch-mudanca

Resolve conflicts (if Hover):

git diff [branch_1]:file-exemplo [branch_2]:file-exemplo

After resolving conflicts (if any) commit the resolution.

seuprojeto (master):git commit -am"PRO-01 conflitos resolvidos"

And finally, push to the master:

seuprojeto (master):git push origin master

PS: see if in bitbucket, vc is listing all commits in the filter:

https://bitbucket.org/conta-empresa/nome-projeto/commits/all

  • So Ivan, I don’t work on the same branch. but when I merge it looks like it was done on the same branch. In your example it was more complete, but I’ll analyze

  • If you disable the fast-foward, using -no-ff in the merge, it will be viewable as you wish, however, you will lose the synchronism line.

0


Through some links here in English I found a question in which I discovered the name of the git function I was looking for, it’s called "FAST-FORWARD" I left it disabled in git by default git config --global merge.ff false

Thank you for your cooperation

Browser other questions tagged

You are not signed in. Login or sign up in order to post.