-1

I am using Git Flow, "A successful Git branching model":
https://nvie.com/posts/a-successful-git-branching-model/

but I do not fully understand it, so I am asking your help.

In our project we are using gitlab and there are 2 branches from the project which is the master and develop.

I was told to branch out from the develop branch so heres what I did:

  1. First is that I clone the remote repository, the default branch is master
  2. Second I branch off from develop branch using the command - git checkout -b develop origin/develop
  3. Now in my local I have two branches master and develop
  4. I have a question when creating a feature branch, is it only locally? like using the command git branch -b feature_branch, is this process correct ?
  5. Now if the above process is correct, and I have my changes on the feature branch should I merge it into the develop branch? is that right?
  6. Now If I want to push my local changes, should I push it to the remote develop branch? or on the master branch?
  7. If I pull changes from my team, should I pull it from the remote master branch? or in the remote develop branch?

Can anyone give a clarification to this, if you can give right commands, I'll appreciate that also, thank you. or a step by step process.

Jonathan Hall
  • 75,165
  • 16
  • 143
  • 189

1 Answers1

1

It depends on your team's workflow, but it's usually safe to do the following:

  1. Clone
  2. git switch develop
  3. git switch -c feature_branch
  4. Commit stuff
  5. git push -u origin feature_branch
  6. Create a pull request into develop on Gitlab
  7. Pull develop before starting a new feature
krisz
  • 2,686
  • 2
  • 11
  • 18
  • Basically in starting a new feature , I have to delete my feature_branch first head back to develop branch and then pull , and then create or start a new feature ? is that right ? –  Mar 29 '20 at 04:20
  • Yes, but I would only delete the feature branch after the pull request is merged. And use a different name for each feature branch even if you deleted the previous to avoid confusion and possible conflict with the remote branch. – krisz Mar 29 '20 at 04:28
  • In this case, I think it is not a must to always pull/rebase to the latest `develop` (although it is preferable and best practice). The reason is, by using this `feature-branch-` (branching out whenever you're working on a feature), it allows you or your other team to work in parallel. If there happened to be a conflict, it will just show up when you're creating a pull request (step no.6). – iomario Apr 10 '20 at 01:22