You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
Steps:
Backup your work you have done.
Delete your local and remote forks.
Refork this repository and clone locally
Create a new branch and then insert your updated code.
Commit the code in question and publish a PR to this repository.
Pros:
- Extremely easy to do
- Can be automated
- Do not have to worry about git getting in the way of committing
Cons:
Git isnt getting in the way when committing
Whenever there are mismatches between your branch and main master branch concerning changes, attention should be paid to such changes. There is usually a good reason why git complains about this.
There might be code that has changed, this way of doing things can possibly create a broken version of the repository if the code is not reviewed carefully
There is a much better way of doing this without reforking.
we can update the master branch locally
git fetch origin master:master can be used to update the master branch even if you are not in the same branch
save your work
delete your branch
git branch -D <branch-name>
make sure you have saved your changes, any changes that are in your remote
remake your branch
git checkout -b <branch-name> master
If you using the same branch-name as the deleted one, then you are going to use --force when pushing
Insert your backed up code and commit it locally
Now its time to push it to your repository
This is where if you named the branch the same as the deleted one where --force
Warning: Be careful this will tell git to ignore differences between what is on your local repository and the remote on github
If you are confident with that you are ready to push you can either push each branch one by one or push them all at the same time
the command to do them all at once is git push origin --all remembering that you need --force if your deleted branch and new branch are the same.
this ensures that your master and any branches you were working on are in sync with the remote
You can then follow opening a PR using the site in github.
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
git rebase master
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
ugh just to make sure that the documentation is correct, there was a mistake in the docs where it was not specified that it was needed to have this repo added as a remote and that it was needed to specify the remote repository (in this case upstream) when fetching. It meant that everyone wasn't pulling from the latest sources. Well that is fixed now in the documentation.
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:master
can 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
--force
when pushing--force
git push origin --all
remembering that you need--force
if your deleted branch and new branch are the same.git merge
.git fetch upstream master:master
can 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.git
git merge master --no-edit
will do thisgit merge --abort
will do this for you and you can start over.git merge --continue --no-edit
git rebase
.git fetch upstream master:master
can 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.git
rebase
git rebase master
git status
to see which files have been marked as modifiedgit add \<file\>
to add the files, or all at once usinggit add -u
git rebase --continue
git -c core.editor=true rebase --continue
The text was updated successfully, but these errors were encountered: