Rebasing Merge Commits in Git | Envato Notes
Thousands of files in a git merge...Hundreds of merge conflicts...Someone will commit before you are done...so just assume...
You will have to rebase the merge before you push it to the remote.
The obvious way, git pull --rebase, not so good...you lose your merge and start over.
This describes a Branch Merge, (merging two branches in a single git clone). Android Repo doesn't do multiple branches - I tried to find an easier way...
1) Install one of the git supported merge tools.
If the merge tool is on the path, git mergetool will automatically call it for each of your merge conflicts - very fast.
merge tool candidates: meld opendiff kdiff3 tkdiff xxdiff tortoisemerge gvimdiff diffuse ecmerge p4merge araxis bc3 emerge vimdiff
(I like meld on Linux, it works with cvs, svn, and git.)
2) Branch Merge: Merge all changes from two branches so that they match in content and point in time.
# Clone the repo containing the branches you want to merge.
git clone xxx
# Get the branch_to_merge
git checkout branch_to_merge
# Bring changes from Master to branch_to_merge.
git merge master
# Resolve any conflicts
git mergetool
# Switch back to branch master
git checkout master
# Bring changes from branch_to_merge to master
git merge branch_to_merge
# Resolve conflicts
git mergetool
# See if there are any differences between the merged branches.
git diff branch_to_merge..master
# Done, start testing...
3) Get any changes since you started merging.
# Before push, get any changes.
git checkout master
# Get new commits from the remote.
git fetch
# Move your merge "aHEAD" of the new commits.
git rebase --preserve-merges origin/master
# You may have a set of conflicts to resolve.
git mergetool
# If there are conflicts, you will be on a detached head. Must continue.
git rebase --continue
# Save the commit message when it comes up.
# At the end of rebase you will be back on master branch.
# Next get these changes to the other branch being merged.
git checkout branch_to_merge
# Get any new commits from the remote branch_to_merge.
git fetch
git rebase --preserve-merges origin/branch_to_merge
git mergetool
git rebase --continue # Upon resolving the conflicts, you will see the commit message again.
# Save it, and you are (almost) done.
# If there were commits on the branch_to_merge,
# switch back to master and merge them in (checkout, merge, mergetool).
# You are at a stable point for pushing your merge again...
# Both local branches should match, no differences.
git diff branch_to_merge..master
# Both branches should match in time.
# You should see your final merge first, at the HEAD of the tree.
git checkout master
git log --oneline --graph
git checkout branch_to_merge
git log --oneline --graph
Thursday, August 9, 2012
Wednesday, June 13, 2012
HowTo: Fix Gerrit 'Failure to submit due to path conflict'
Failure to submit due to path conflict but no real conflict. - Google Groups
Git Tools - Stashing
While there's a lot of discussion, there's no real howto to fix things up using repo using three simple commands.
Gerrit won't merge when someone is too slow to merge your changes, you've ameded your merge...A change came in before your change was merged...it happens...a lot.
repo start [branchname]
# You've made your changes and sent them to Gerrit...
repo upload
Gerrit merge fails. Here's HowTo fix it.
# Get on your repo start [branchname]
git checkout [branchname]
# Find the name of the remotebranch you are merging to with Gerrit.
git remote
[remotebranch]
# Your local changes need to be stashed for now.
git stash
# Fix your branch so you can merge with Gerrit.
git rebase[remotebranch]/master
# Reapply any local changes
git stash apply
# Amend the commit on your fixed branch.
git add .
git commit --amend
# After upload, you should see a new patch to your merge in Gerrit.
repo upload
# Get rid of stashed changes that have been merged
git stash clear
At this point, you should be able to review and merge in Gerrit, hurry up :)
Git Tools - Stashing
While there's a lot of discussion, there's no real howto to fix things up using repo using three simple commands.
Gerrit won't merge when someone is too slow to merge your changes, you've ameded your merge...A change came in before your change was merged...it happens...a lot.
repo start [branchname]
# You've made your changes and sent them to Gerrit...
repo upload
Gerrit merge fails. Here's HowTo fix it.
# Get on your repo start [branchname]
git checkout [branchname]
# Find the name of the remotebranch you are merging to with Gerrit.
git remote
[remotebranch]
# Your local changes need to be stashed for now.
git stash
# Fix your branch so you can merge with Gerrit.
git rebase
# After upload, you should see a new patch to your merge in Gerrit.
At this point, you should be able to review and merge in Gerrit, hurry up :)
Thursday, May 24, 2012
HowTo: Build GDB for ARM on Fedora 17
http://www.linuxquestions.org/questions/linux-newbie-8/no-termcap-library-found-when-building-gdb-879757/
Found a need to build a cross gdb, just one more time...It comes with a simulator...
yum install ncurses-devel texinfo gettext flex bison expat-devel sharutils dejagnu glibc-static libunwind-devel valgrind gcc-c++ gcc-gfortran readline-devel rpm-devel python-devel texinfo-tex
# Ada compiler (may not be available in cross compiler)
yum install gnat
Found a need to build a cross gdb, just one more time...It comes with a simulator...
yum install ncurses-devel texinfo gettext flex bison expat-devel sharutils dejagnu glibc-static libunwind-devel valgrind gcc-c++ gcc-gfortran readline-devel rpm-devel python-devel texinfo-tex
# Ada compiler (may not be available in cross compiler)
yum install gnat
Monday, April 9, 2012
HowTo: Ubuntu unknown user in statoverride
Tip : syntax error: unknown user ‘munin’ in statoverride file « OpenWebTech.fr
I installed virt-goodies on Ubuntu 10.04, and then nothing else would install. Even after uninstalling...A user called munin...
While the fix is easy...I could only find it in France, so here we go:
I installed virt-goodies on Ubuntu 10.04, and then nothing else would install. Even after uninstalling...A user called munin...
While the fix is easy...I could only find it in France, so here we go:
grep 'munin' /var/lib/dpkg/statoverride#You should have the following lines:#To solve the problem simply remove them with a little sed:#grep 'munin' / var / lib / dpkg / statoverride #difference difference 755 / var / lib / difference #difference difference 755 / var / www / difference #difference difference 775 / var / lib / difference / plugin-state #root munin 750 /etc/munin/plugin-conf.d #munin munin 755 / var / cache / munin / www #munin adm 750 / var / log / munin
sed -i '/munin/d' /var/lib/dpkg/statoverride
Tuesday, March 6, 2012
HowTo: Fix Vi Backspace and delete problems
Backspace and delete problems - Vim Tips Wiki
Coming into a Suse system, vi didn't do colors, and the backspace key wasn't working...Here are three obscure things found when logging into lots of different systems.
Add these lines to your ~/.vimrc file.
NOTE: Use the real backspace key for ^?
You may also need to fix the backspace key in the terminal. Put something like this in your .profile, .bashrc, whichever works.
Some systems don't add a .profile to your user account. No problem until you log in remotely (i.e. ssh), then you get a warning, can't find your profile, screen doesn't look right...
Coming into a Suse system, vi didn't do colors, and the backspace key wasn't working...Here are three obscure things found when logging into lots of different systems.
Add these lines to your ~/.vimrc file.
NOTE: Use the real backspace key for ^?
syntax on
imap ^? You may also need to fix the backspace key in the terminal. Put something like this in your .profile, .bashrc, whichever works.
stty erase '^H'
Some systems don't add a .profile to your user account. No problem until you log in remotely (i.e. ssh), then you get a warning, can't find your profile, screen doesn't look right...
ln -s ~/.bashrc ~/.profile # In case you don't have a .profile, get one this way.
Friday, March 2, 2012
HowTo: search for files excluding binary files on Linux
search for files excluding binary files - The UNIX and Linux Forums
An old problem with CVS is that you need to identify the binary files as you add them in (cvs add -kb). Otherwise, the next version will do an ASCII merge, trash the previous version, and you won't know until you try to restore an old version. Mostly happens when moving between Linux and Windows. Thanks to zazzybob, this will find ASCII files really well, and save me a bunch of work.
find . -type f -print | xargs file | grep "ASCII\|HTML\|text\|XML" | cut -d: -f1
Finds all binary files (almost) but very close...With the CVS problem, 'cvs add' the known good ASCII files, and any that are missed won't be re-added...
find . -type f -print | xargs file | grep -v "ASCII\|HTML\|text\|XML" | cut -d: -f1
An old problem with CVS is that you need to identify the binary files as you add them in (cvs add -kb). Otherwise, the next version will do an ASCII merge, trash the previous version, and you won't know until you try to restore an old version. Mostly happens when moving between Linux and Windows. Thanks to zazzybob, this will find ASCII files really well, and save me a bunch of work.
find . -type f -print | xargs file | grep "ASCII\|HTML\|text\|XML" | cut -d: -f1
Finds all binary files (almost) but very close...With the CVS problem, 'cvs add' the known good ASCII files, and any that are missed won't be re-added...
find . -type f -print | xargs file | grep -v "ASCII\|HTML\|text\|XML" | cut -d: -f1
Wednesday, February 22, 2012
HowTo: check if a file exists in a makefile (using makefile conditionals)
How to check if a file exists in a makefile - Stack Overflow
There are so many examples with redundant uses of wildcard
$(findstring., $(wildcard *.))
Use the "wildcard" function:
ifeq ($(wildcard $(HEADER_FILES)), )
# This will stop the make trying to resolve HEADER_FILES for echo :)
echo "ERROR: $(HEADER_FILES)"
else
# File exists, continue or do something else...
endif
There are so many examples with redundant uses of wildcard
$(findstring
Use the "wildcard" function:
$(wildcard *.h)
EDIT: in order to match a specific list, do$(wildcard $(HEADER_FILES))
There is no need to use $(filter ...), the wildcard function automatically filters files which don't exist.ifeq ($(wildcard $(HEADER_FILES)), )
# This will stop the make trying to resolve HEADER_FILES for echo :)
echo "ERROR: $(HEADER_FILES)"
else
# File exists, continue or do something else...
endif
Subscribe to:
Posts (Atom)