Git work flow!


#1



I have a question which confusing me a lot.

This is the work flow of git.
1,Fetch and merge changes from the remote
2,Create a branch to work on a new project feature
3,Develop the feature on your branch and commit your work
4,Fetch and merge from the remote again (in case new commits were made while you were working)
5,Push your branch up to the remote for review

i give you an example:
1, do git clone first
remote Sally branch A->B->C


local master branch A->B->C

2,do fetch and merge
remote Sally branch A->B->C->D


local master branch A->B->C->D

3, do feature on my own branch, but at the same time remote branch also changed.
remote Sally branch A->B->C->D->E


local master branch A->B->C->D->F

the questions is, how the 3rd step merge???
remote branch be fetched to origin/master,then local master branch merged it to be A->B->C->D->E->F??


Git workflow help me!
#2


There is a question, please see my example first.

This is the work flow of git.
1,Fetch and merge changes from the remote
2,Create a branch to work on a new project feature
3,Develop the feature on your branch and commit your work
4,Fetch and merge from the remote again (in case new commits were made while you were working)
5,Push your branch up to the remote for review

I give you an example which is actually as same as codecademy ask me to do.
1, do git clone first
remote Sally branch A->B->C


local master branch A->B->C

2,do fetch and merge
remote Sally branch A->B->C->D


local master branch A->B->C->D

3, do feature on my local bio-questions branch
remote Sally branch A->B->C->D


local master branch A->B->C->D
local bio-questions branch A->B->C->D->F

Codecademy ask us to create a new branch named bio-questions.
1,why we need this bio-questions? can we just work on local master branch?
2,when we work with bio-questions branch, if remote branch is changed to be A->B->C->D->E,
my question is how to do with the merge process. to fetch and merge to local master branch or local bio-questions-branch??

really confusing. hope some one can help me.


#3

Don't you mean the 4th? You'd do it same way as the first time. If there are conflicts then you would need to resolve them.

The master branch might be used for obtaining the latest version and shouldn't be in a broken state at any time.

The two branches that need to be merged are Sally/master and Your/bio-branch

If Sally is reviewing your feature before merging into her master, then you would want to make sure that there are no conflicts when she merges. You would accomplish that by merging Sally/master into Your/bio-questions which would allow Sally to do an automatic merge since they are identical. Or if there are no conflicts then you wouldn't need to merge anything before sending the changes.

If you are making changes to the remote master branch yourself, then you would fetch its master branch to update your own, merge Your/bio-questions into that and then send the changes back.


#4

Much thanks for your explaination,still some questions.
You mean if Sally/master changed, i need to merge Sally/master to my My/bio-questions first, then i send a pull request to Sally ask her to merge My/bio-questions .
But how about My/local master branch, it will not be updated, i just leave it alone right?
Actually my understanding is i should merge updated Sally/master to My/local master branch,then merge My/bio-questions into My/local master branch, then send pull request to ask Sally merge my local master branch. but if i do so,why i don't just make change in my My/local master branch and send to Sally directly? totaly no need My/bio-questions.

Also what do you mean if you are making changes to the remote master branch yourself? In this case you mean if make change to Sally/master?


#5

If you wanted to get the latest version of the remote master branch, then you would update your master branch from that remote. (For example if you want to build the latest official version of the software, or if you need the latest master branch so that you can create a new branch from it)

If you were to want to modify the remote master directly, then you would update your master branch, apply changes, and push it back. Or merge into Your/bio-questions and push that to the remote master.

Either you have permission to make changes to that remote branch directly, and you'd be the one merging it in, or it might be controlled by someone else that would have to accept your changes by merging it in themselves.
So either you do the merge yourself, or you make sure it's easy for somebody else to do it so that they only have to tend to what only they can do.

As for what you ever "should" do, that's a matter of what you want to do. Git is just a tool, up to you what you do with it. It tracks history and makes promises about integrity of the repository

You could merge Sally/master directly into Your/bio-questions.
Pull requests is specific to git-hub, that's not something git does. How exactly you send the changes is a matter of organization, you can just as well e-mail them a patch for them to consider.


#6

Thank you for your quick comment.I made some edit when you were answering me.Could you refer to my question above,
but if i do so,why i don't just make change in my My/local master branch and send to Sally directly? totaly no need My/bio-questions.


#7

As long as your master branch isn't where people would get the latest version, you could do that. Your feature might be in a separate branch on the remote though (perhaps somebody wants to be able to see what you're doing, perhaps multiple people are working on that feature before it's getting merged into the master branch), and then it starts getting confusing if the names of the branches on the two repositories aren't corresponding. You might be working on multiple things, you might need to create new branches from master. You might want to update your master to re-build their version.


#8

Oh, i got you. So when someone is able to review my master branch, i am another Sally!!.

thanks!!


#9

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.