Welcome to Software Development on Codidact!
Will you help us build our independent community of developers helping developers? We're small and trying to grow. We welcome questions about all aspects of software development, from design to code to QA and more. Got questions? Got answers? Got code you'd like someone to review? Please join us.
Comments on Is it a good idea to have a permanent branch for a feature?
Parent
Is it a good idea to have a permanent branch for a feature?
I'm rather new to using git, so I'm not sure about the best practices regarding it. I have a feature branch branched off, and periodically when the feature needs to be updated I will add some commits to the branch and then create a pull request.[1]
Is it a good idea to have a permanent branch for this feature, or should I delete it after merging and create a new branch whenever an issue comes up? Right now I'm doing the former, but I've also heard that branches should have a single purpose so I'm not sure if it's actually a good idea.
Basically, should I do
-
Update feature branch -> Merge -> Update feature branch -> Merge
---O--O---O--O----O--- \__\_/____\__/____
or
-
Create feature branch -> Merge and delete branch -> Create new branch -> Merge and delete branch
---O--O---O-O-----O--- \__\_/ \___/
-
It's for the Code Golf leaderboard, if you were wondering. ↩︎
Post
You may know me so I am answering :P (someone close to you but you can't find me directly).
Is it a good idea to have a permanent branch for a feature?
Suppose, you have a permanent branch then you had PR 1 years later. Of course, there will be lots of changes in develop branch. But, you forgot to merge them in your branch. Suppose, in that PR you had made changes to line 10 page B. But, in develop branch they had deleted those lines and, they don't need those things anymore. So, your PR is useless. But, if go to merge develop to your branch then your PR then your code will be lost either.
Making the time more shorter : Now, you are going to PR 5 days later. Suppose, the following code was looking like this in your branch.
if(a<b){
System.out.println(b+" is greater than "+a);
}
You had commited that [1]
if(a<b){
System.out.println(a+" is less than "+b);
}
But, in develop staffs had already done that. Or, removed SOUT and added something else. If you go to merge then your commit will be lost.
If you just commit in page A and, other developers don't touch that page than you can permanently use a branch rather than creating new ones. Cause, it won't affect much more. Most of your commit was on Codegolf.js so, if you want you can use a permanent branch. But, if you want to work on other files then you can use "temporarily" branch.
-
I know both context represent same thing. I am just giving an example. ↩︎
0 comment threads