Encourage clean PRs when working on existing projects#1785
Encourage clean PRs when working on existing projects#1785OracPrime wants to merge 2 commits intoCodeYourFuture:mainfrom
Conversation
👷 Deploy request for cyf-curriculum pending review.Visit the deploys page to approve it
|
👷 Deploy request for cyf-piscine pending review.Visit the deploys page to approve it
|
👷 Deploy request for cyf-sdc pending review.Visit the deploys page to approve it
|
👷 Deploy request for cyf-common pending review.Visit the deploys page to approve it
|
👷 Deploy request for cyf-itd pending review.Visit the deploys page to approve it
|
👷 Deploy request for cyf-tracks pending review.Visit the deploys page to approve it
|
👷 Deploy request for cyf-launch pending review.Visit the deploys page to approve it
|
illicitonion
left a comment
There was a problem hiding this comment.
Thanks! One suggestion/thought
| We should (almost!) always work from a clean copy of main. When you move from one task to the next, do not keep the changes from the previous task. Often in the real world your last PR will be merged to main before you branch for the new task, so you will have the changes included in the second task's PR, but they are not part of the branch, they are there as part of main. When doing these exercises (or in real world scenarios where your previous branch hasn't been merged) it is important to start from a clean checkout of main. You can do this before you start on the second task by using | ||
|
|
||
| ```plain | ||
| git reset --hard origin/main |
There was a problem hiding this comment.
This is a useful "I already made my branch wrong I need to fix it" command, but I read your text above as suggesting this is for creating a new branch?
Do we want to suggest:
git switch --create new-branch main
as a default way to make a new branch, and give the reset command as an "If you already created your branch and need to undo things" command?
There was a problem hiding this comment.
Good point. Further commit incoming
| git switch -c new-branch main | ||
| ``` | ||
|
|
||
| which will remove your committed branch and create a new one based on main. |
There was a problem hiding this comment.
| which will remove your committed branch and create a new one based on main. | |
| which will create a new one based on main, and switch to it. |
| If you've got random uncommitted changes in your local folder, they will not be removed by the above command. So before you do that command you can clean things up: | ||
|
|
||
| ```plain | ||
| git reset --hard origin/main |
There was a problem hiding this comment.
As I read this, this risks people resetting their old branch to origin/main rather than "the committed tip of the branch being updated"?
| git reset --hard origin/main | |
| git reset --hard HEAD |
Add a new paragraph to encourage trainees to include only the changes for the particular task in a PR, not previous ones too