0

I am working on a project and some other developers also part of this project and we keep our works in Git.

According to the Create and merge a git branch to an epic branch question, On top of this, I have some other questions as well. I am following the below way to commit my changes,

created my branch feature/myVersion from the epic branch feature/version-1 and doing my implementation. Before I commit to the epic branch if another developer merged a feature branch to the epic branch before I commit and merge my branch to epic. I am doing the following to update my branch with epic. Is it the correct way?

git stash (stash my local changes)

=>Do I really need to fetch here. If yes why?

git rebase origin/feature/version-1

=>Do I really need to push here. If yes why?

git stash apply

git add .

git commit -m ""

git push origin feature/myVersion

and also I always create a new branch from the epic branch when I create a new feature of this epic branch. Is it the correct way or create a new branch from the branch is correct(For example create a feature/myVersion-1 branch from feature/myVersion branch or feature/myVersion-1 from the epic branch feature/version-1 is correct?)

Community
  • 1
  • 1
Hariprasath
  • 539
  • 1
  • 9
  • 21

1 Answers1

0

You shouldn't need stashing at all.

You are looking for something like this:

on feature/myVersion

git add .
git commit
git pull origin feature/version-1
git rebase feature/version-1 OR git merge feature/version-1*
git push

*depending on whether it's okay to re-write history for this branch

Christos Batzilis
  • 352
  • 1
  • 3
  • 12
  • Here I am stashing to avoid any conflict. It doesn't matter for stashing here. I just hide my changes and rebase the epic to my branch and pop the changes. Why we need to pull instead of fetch and one more thing if you pull the changes you don't need to rebase at all. Please validate this. – Hariprasath Jun 14 '18 at 09:20
  • pull is actually fetch+merge, meaning that it does not only update the contents of the remote branch but it also merges them to the local one. My understanding here is that you want to 1. fetch the changes of your parent branch feature/version-1 from the server and 2.bring them into feature/myVersion. 1. is achieved by git pull and 2. by git rebase . – Christos Batzilis Jun 14 '18 at 09:34