DelNov / T-Flows

Program for Simulation of Turbulent Flows
Other
113 stars 50 forks source link

Question on git #72

Open Niceno opened 5 years ago

Niceno commented 5 years ago

Dear guys, Egor in particular,

I have an issue with git command. My usual workflow is lately like this:

git clone https://github.com/DelNov/T-Flows
git checkout -b bojans_branch_to_fix_issue_#67

Then I am fixing the issue for a while. When happy, I do:

git commit
git push --set-upstream origin bojans_branch_to_fix_issue_#67

Then I go to our page (https://github.com/DelNov/T-Flows), find the branch I created to debug, and press a green button which says: "Compare & pull request"

Is this a good workflow or not?

palkinev commented 5 years ago

This way you push to git DelNov repository and create new branch automatically (if does not exist).

Then you make a pull request via git website and assign a reviewer.

I see one minor problem with this approach: I can edit your pull request directly, approve it and merge (if I am not careful I can ruin your pull request). I did it today at the morning though I was cautions.

My advice is to add locally extra remote repository to push - your fork. Then push there when you are ready and pull request is safe and can not be changed by anyone except you.

Therefore, I advice to change git workflow according to file Documentation/git_workflow_guide 1) git clone https://github.com/DelNov/T-Flows git checkout -b bojans_branch_to_fix_issue_#67 2) git remote add my_fork https://github.com/Niceno/T-Flows-Last-Amg git remote -v 3) when you are ready to push commits: git push my_fork bojans_branch_to_fix_issue_#67:branch_on_remote_repository Warning: no spaces are allowed before or after colon sign :

branch_on_remote_repository will be created if does not exist as separate branch on your personal fork. And then you can create git pull request

Niceno commented 5 years ago

Hmm ... I am not sure this is entirely possible (but I could be wrong) because I found out that it's not possible to have more than one fork in your GitHub environment. That is why I have the fork T-Flows-Last-Amg for long-term development (in this case of AMG solver) and use only branches for quick fixes of issues.

I also have to admit that difference between branches and forks didn't sit super well in my mind. Maybe, but is up to discussion, we should:

  1. Use forks for larger development endeavors (say implementation of new physical models, combustion, Lagrangian particle tracking etc ...)
  2. Use branches for small fixes (like I fixed mass flux issue today)

What do you think?

Niceno commented 5 years ago

Is this article of any help to establish our (best practice) work flow?

https://nvie.com/posts/a-successful-git-branching-model/?fbclid=IwAR3h1EYuGy4MeDbb2c8-KoJCjARrZmwHSo45V_A-FWTvRx5RPimCfeiFbRE#the-main-branches

palkinev commented 5 years ago

We actually have already pretty similar git tree structure: screenshot_2018-11-14_21-08-49 4 lines for 4 persons we have and 5th as DelNov.

About forks and branches: Fork is just a copy of initial DelNov repository, which belongs to single unique git account. It is up to you to keep this fork updated or make entirely new separate project like PSI Boil C++, but our goal is collaboration, or make 1000 branches with new features you want to work with.

Bojan, you do not need more than one fork, instead you can have multiple branches on remote repository.

Take a quick look at my T-Flows fork: https://github.com/palkinev/T-Flows/branches

I have a few branches there. If I work with cgns issue I push my commits there, if I will work on Sources for Hanjalic Jakirlic then I will work with that branch. If I see that Massimo made a pull request and I want to check it, I pull his branch with the code he wants to be accepted in the main branch to my temporal new local branch called, for example, massimo_branch. I saw some irregularities in his code like 3 spaces instead of 4, extra spaces after line of code, so I corrected that myself and did not asked him to do it.

After that I pushed changed to my new remote branch on my fork and made a pull request from there to his fork and branch he had for pull request (I could have made new pull request from this point to DelNov, but I in this case I had to decline his pull request). If he would accepted that, then his fork would changed and thus updated his pull request automatically. I made another (third move already): I pushed directly to his branch on his fork since I have been working to improve his code he proposed. And thus git request was automatically updated.

Just remember to pull changes from DelNov whenever you switched to work with new branch.

palkinev commented 5 years ago

there are some guides how to work in collaboration with git:

http://www.eqqon.com/index.php/Collaborative_Github_Workflow

Niceno commented 5 years ago

Wow man, your branches are pretty cool! Concerning irregularities in Massimos's source, thanks for fixing it, but it would also be useful if you simply rejected his pull request and asked him to correct it himself :-)