Are you new to open source? If so, hopefully you have taken advantage of Hacktoberfest to get your feet wet. It's an exciting feeling to get your f...
For further actions, you may consider blocking this person and/or reporting abuse
What you can also do is just having feature branches in your fork, and rebase then to master to update. If your confident with rebasing that might be easier.
Could you please explain how rebase works? That concept has always confused me.
Say you have made one commit, changing two files. In the mean time on master there had been 5 additional commits. To make this easily mergeable you can 'pretend' you applied those two changes after the 5 new commits.
When non of those files where changed in the other 5 commits this will go fine. When there where changes made, there is a conflict and you need to merge you commit that's applied again, with the new commits.
Your rewriting history in such a way that the commits are not ordered strictly in time, but when they where about to be merged.
If you do this before ever merge you get a flat history that is easy to follow.
You can also do some other fancy stuff while rebasing, like changing the commit message, merge multiple commits to one, or skip a commit.
These things will bother make it easier to review a pr, because it's much clearer what you changed compared to a pr with a lot of merges in it, and will keep master cleaner.
I mostly use IntelliJ to rebase, it makes resolving conflict very easy.
Thank you @gklijs for the detailed reply. So when you "pretend" you applied those two changes after the 5 new commits, does it actually do it, or is it only a dry-run? I guess I will need to test this out for myself to really understand how it works..but your explanation helped, I'll come back to this for reference :)
Be sure to push your branch to your fork before you start rebasing. In that case you can always restore the branch in case something goes wrong. After the rebase, make sure all the tests run, and your code (those two changes) are still there. If it's all good you can force push
git push -f
your local branch to your fork.If you do it like that there no risk losing something. You shouldn't work with multiple people on the same remote branch, because then there is a risk of losing stuff. Ideally features are small enough to be done by one person. In case you do need to work together on the same branch, and still like to rebase, each person should work in it's own forked branch, and can rebase on the other fork when needed.
Thank you for the tips! Much appreciated!
Rebase “replays” your commits (with new commit hash) on the current top of the originating branch. :)
Thank you @tomlincoln93 !
Maybe it's just me but I find it's much easier to have
origin
being... well theoriginal
repo and not my fork.Before I used to clone lots of project where I actually never did any changes. What's the point?
If
origin
is the original repo, then I just need to checkoutmaster
and dogit pull
To update a branch where I worked, I just need to do
git fetch origin -v && git merge origin/master
I have some zsh aliases to help with it
Why worry about keeping my fork up to date?
I create all new branches from upstream/master so never a branch out of sync
how does this play out ? more like how is it done?
Would this work if you have made changes to your local fork and there are conflicts?
Nice. This is awesome.
😀
😀
This has been a lifesaver, especially for Hacktoberfest - Thank you so much Rane! 🕺