I am the sole developer working on a fairly big project. I made several important changes in master
and I'm about to resume working on a feature
branch that has fallen behind a good deal. The feature
branch really does need the changes from master
but I do not want to merge the changes into master
until the work on feature
is ready for release. I think this is a pretty straight forward case for rebasing, but I am not sure. Below is a very boiled down version of my situation (the actual history is much longer).
* 0e109d5 - (HEAD, origin/master, origin/HEAD, master) latest commit
* 9188511 - major schema change
| * d3472a5 - (origin/feature, feature) feature branch commit
| * 6c36837 - Start of feature branch
|/
* 80d93a8 - Base commit
feature
to the remote for safe-keeping, which is normally a bad thing for rebasing. But since it hasn't been shared with anyone else, can I simply delete the remote branch and continue like it never existed? My remote
is there simply for offline storage and security (it is a plain git server, not github).master
onto feature
and just continue working on feature
without also fast-forwarding master
to the last feature branch commit?feature
pretty much needs all the changes in master
.HEAD
and try applying it to feature
.Any advice is appreciated. I love git, but I have no experience rebasing yet.
Go to your local project and check out the branch you want to merge into (your local master branch) $ git checkout master Fetch the remote, bringing the branches and their commits from the remote repository. You can use the -p, --prune option to delete any remote-tracking references that no longer exist in the remote.
If your local branch didn't have any unique commits, Git will instead perform a "fast-forward". Merge your (now updated) master branch into your feature branch to update it with the latest changes from your team. Depending on your git configuration this may open vim. Enter a commit message, save, and quit vim:
Merge Local Branch with Master without missing Changes Step 1: Stash your local working branch changes. Checkout to your local branch. Make new changes to your local branch. Step 2: Update your local master branch with remote. Checkout to the master branch. You can use the git branch command... Step ...
To update other branches like (backup) with your master branch copy. You can do follow either way (rebase or merge)... Do rebase (there won't be any extra commit made to the backup branch). Merge branches (there will be an extra commit automatically to the backup branch).
I think what you want here is to rebase
feature
onto master
. Just do:
git rebase master feature
If you are currently on feature
branch, just:
git rebase master
For your questions:
It deosn't matter since you are the sole developer. After the rebase
, just push to your remote branch with -f
or --force-with-lease
. The latter one is more safe, but no difference here for sole developer.
git push --force-with-lease origin feature
Yes, you don't need to fast-forwarding master at the moment. You can do it after you finish work on feature
. You can use --ff-only
to allow only fast-forward merge to keep your history linear.
git checkout master
git merge --ff-only feature
Yes, no cherry pick
is needed here.
No need to use patch. Patch
is used to distribute your changes to others.
PS. git
is really friendly with patch
. You can do it either way as follows.
git diff > some.patch
git apply some.patch
Or
git diff > some.patch
patch -p1 < some.patch
Or
git diff --no-prefix > some.patch
patch -p0 < some.patch
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With