It has come to my attention that for more intricate issues, there have been issues with sending PRs to the repository.
I will outline 3 ways to create clean PRs and their pros and cons.
- Deleting and reforking from Upstream (this repository).
I figure most of you know how to do this and probably are doing this.
- Better way 1: using
git merge.
- Steps:
- Update the master branch locally
git fetch upstream master:master can be used to update the master branch even if you are not in the same branch
- make sure that you have my branch set to upstream
git remote add upstream git@github.com:MichaelPachec0/nodejs-project-night.git
- we merge the master into your working branch
git merge master --no-edit will do this
- There is a chance that there will be scary error messages. If so go back to vscode, there should be files in the explorer that will have a ! next to them, review the conflicting changes and decide you want keep the changes that master has (Accept Current Change) or if you want your code to overwrite whats currently in master (Accept Incoming Changes). Once you have fixed all the conflicts in a file, make sure you save the file and go to the next one. If you are unsure, you can contact me or ask in group chat and ask.
- At anytime if you feel like you made a mistake you can always back out
git merge --abort will do this for you and you can start over.
- Once all the conflicting changes are fixed go back to your terminal and let git know it can continue
git merge --continue --no-edit
- Now branch should be clean and ready to push.
- Time to open a PR on github.
- Pros:
- It is less prone to give you problems compared to the next way.
- You dont need to go through all the hassle of deleting and reforking.
- Git will warn you when there are conflicting changes.
- Cons:
- There is more work when merging.
- Merging can be can have scary looking messages, and sometimes you dont know whether or not you overwrite whats on master.
- There will be merge commits on top of your actual work, which might make it slightly annoying to review
- Better way 2: using
git rebase.
- Steps:
- Update the master branch locally
git fetch upstream master:master can be used to update the master branch even if you are not in the same branch
- make sure that you have my branch set to upstream
git remote add upstream git@github.com:MichaelPachec0/nodejs-project-night.git
- we merge the master into your working branch this time using
rebase
- There very likely chance that rebase will complain output scary messages in the terminal. as with "Better way 1", use vscode to go over the changes.
- Once all the conflicting changes are resolved go back to your terminal and add the files that have edited
- use
git status to see which files have been marked as modified
git add \<file\> to add the files, or all at once using git add -u
- You are ready to tell git to continue.
git rebase --continue
- This will open an editor in case you want to edit your commit
- Time to push.
- Making sure that everything worked, open a PR with the changes ready to be merged.
- Pros:
- Same as "Better way 1" except you will get more warnings
- A big plus is that only the commits that matter get pushed, meaning no extra merging commits
- Cons:
- Same as "Better way 1" with the exception of getting more warnings and more work
- Much more work, im not kidding on this
It has come to my attention that for more intricate issues, there have been issues with sending PRs to the repository.
I will outline 3 ways to create clean PRs and their pros and cons.
I figure most of you know how to do this and probably are doing this.
Steps:
Pros:
- Extremely easy to do
- Can be automated
- Do not have to worry about git getting in the way of committing
Cons:
git fetch origin master:mastercan be used to update the master branch even if you are not in the same branchgit branch -D <branch-name>git checkout -b <branch-name> master--forcewhen pushing--forcegit push origin --allremembering that you need--forceif your deleted branch and new branch are the same.git merge.git fetch upstream master:mastercan be used to update the master branch even if you are not in the same branchgit remote add upstream git@github.com:MichaelPachec0/nodejs-project-night.gitgit merge master --no-editwill do thisgit merge --abortwill do this for you and you can start over.git merge --continue --no-editgit rebase.git fetch upstream master:mastercan be used to update the master branch even if you are not in the same branchgit remote add upstream git@github.com:MichaelPachec0/nodejs-project-night.gitrebasegit rebase mastergit statusto see which files have been marked as modifiedgit add \<file\>to add the files, or all at once usinggit add -ugit rebase --continuegit -c core.editor=true rebase --continue