I'm trying to close an old branch that is no longer used but every time I do the close command on this branch it says a new head is created. Other branches do not have this issue. Does anyone know what my issue could be?
jchan#jchan-Z170N:~/eclipse-workspace/filtec-src/src$ hg --version
Mercurial Distributed SCM (version 3.7.3)
...
jchan#jchan-Z170N:~/eclipse-workspace/filtec-src/src$ hg update -r version1.5.11 -C
1367 files updated, 0 files merged, 6050 files removed, 0 files unresolved
jchan#jchan-Z170N:~/eclipse-workspace/filtec-src/src$ hg commit --close-branch -m "closing legacy branch"
created new head
when i query the list of branches again this branch keeps showing up:
hg branches
...
version1.5.11
Why is this? I am using mercurial command line on Ubuntu 16.04.
Found that I was able to use the tortoise Hg tool "thg" to search and find all the head commits on the miss behaving branch and then merge them all together. After merging all these similar heads together I was able to close the final head and now this branch no longer comes up in the hg branches query.
Related
I face a merge conflict when I would like to rebase the develop branch against my feature branch. I use IntelliJ Idea to execute individual Git commands. Let's say I have 3 pushed commits and I want to squash and rebase them using --interactive mode.
I select all three commits, I select squash, do some rewording, and hit Rebase.
The process fails and an Excel file that appears in the Git panel among Changes and on the diff panel, says the contents are the same. I can only abort or retry the rebase, but continuing doesn't make sense as the change always prevents me to continue.
Here is the console output:
12:50:42.385: [myapplication] git -c credential.helper= -c core.quotepath=false -c log.showSignature=false -c core.commentChar= rebase --interactive develop
Rebasing (1/2)
error: Your local changes to the following files would be overwritten by merge:
excel-file.xlsx
Please commit your changes or stash them before you merge.
Aborting
hint: Could not execute the todo command
hint:
hint: fixup 37d1fc57dff9c7e9a312c88cf78c176cb71dbb47 CommitMessageIsHere
hint:
hint: It has been rescheduled; To edit the command before continuing, please
hint: edit the todo list first:
hint:
hint: git rebase --edit-todo
hint: git rebase --continue
Could not apply 37d1fc5... CommitMessageIsHere
Is there a trick to overcome this obstacle? Is possible to somehow force ignoring and skipping such merge conflict?
You started your rebase with un untracked copy of excel-file.xlsx, and when git met a commit which included the action "create a new excel-file.xlsx file", he stopped.
You have to somehow put aside this untracked version before proceeding.
The simplest way is:
rename that file on disk:
mv excel-file.xlsx excel-file.xlsx.tmp
run git rebase --continue:
either IntelliJ has a button which looks like "proceed with the rebase", or you can run this command from the command line,
once the rebase is complete:
you can compare the contents of both files, and decide what the correct action is -- update the tracked version, delete the tmp file ...
I have looked all over and followed several different sets of instructions on this but none seems to work for me.
I have a GitHub repository and I have made some changes on my local machine and some on my Linux server and was hoping to merge the two.
In the past, I have used the git stash command and then been able to pull and then pop the stash to merge. I have never done this on Linux but I assumed it would the same as windows. However, even though I have stashed my changes on the server I am still unable to pull and receive this error:
error: Your local changes to the following files would be overwritten by merge:
aFolder/aDifferentFolder/aFile.py
So naturally I checked to see if my stash had gone through using git stash show and I got confirmation that the stash existed because the top line showed this:
aFolder/aDifferentFolder/aFile.py | 2110 +++++++++++++++++++++++++++++++++++++++----------------------------------------
This is very strange. But decided that I didn't even want my changes on the server that much anyway so I decided to delete them using git reset --hard and then tried to pull and was met with the same error!
So in summary a list of things I have tried:
git stash
git reset --hard
git clean -f
git add . && git stash
git reset aFolder/aDifferentFolder/aFile.py
EDIT: Just to add more info here is the message I get upon calling stash:
Saved working directory and index state WIP on master: 1d49f3a Merge branch 'master' of https://github.com/username/repository
HEAD is now at 1d49f3a Merge branch 'master' of https://github.com/username/repository
I never found out why this happened but a solution that worked for me was creating a new branch pushing to that and then merging with the master branch. Afterwards I deleted the useless branch.
we have the following situation:
At time point t0, we took snapshot of C++ project in Unix, which was not finished (release 1702 under Unix), and worked on it migrating to Linux. This was established as Master in a new GIT server.
At time point t1, I created a new branch from Master called 1702, and overwrote everything with the up to date Unix code.
During t1, I made another branch linux_not_working, which is a clone of Master branch.
Now, I tried to merge 1702 into linux_not_working, with git mergetool for handling conflicts, and the result is bad: for example I modified all of the project's Makefiles to work in Linux, and the merge did not even display conflicts, just replaced them with the old Unix ones from 1702 branch, also I did not find how to tell vimdiff to take ALL from REMOTE and not LOCAL (as I understand it, BASE has no meaning in this particular merge).
How best to perform this merge, when in a sense, I have two Masters going? I need to take any new additions from 1702, while KEEPING my customizations in linux_not working (manually, but its a lot of files so cherry pick is not ideal).
Any suggestions for the future? They are going to have to do it at least once more, while a contractor is working on 1703 release, and only later production development will shift to Linux.
Essentially, what I want to do is for GIT to tell me for each file: "File R and L are different, which one you want to keep? (allowing me to take different parts of each, IF it happened to have been modified by both branches)"
Thanks!
Essentially, what I want to do is for GIT to tell me for each file: "File R and L are different, which one you want to keep? (allowing me to take different parts of each, IF it happened to have been modified by both branches)"
If you don't need 3-way merge, you can simply check out the content of the branch and review the change with git gui.
$ git checkout -b manual-merge linux_not_working
$ git checkout 1702 . # overwrites source with 1702's one
$ git gui # take or leave each diff
$ git commi
(Or you may want to do it backwards.)
$ git checkout -b manual-merge-2 1702
$ git checkout linux_not_working .
$ git gui
$ git commit
Once you have manually-merged result, you can overwrite and commit as a merge.
$ git checkout 1702
$ git merge linux_not_working
$ git reset
$ git checkout manual-merge . # or manual-merge-2
$ git commit
When I try to perform a patch using:
git am 0001-someFile.patch
but I get this error:
error: patch failed: src/***/file.c:459
error: src/***/file.c: patch does not apply
Patch failed at 0001 someFile.patch
When you have resolved this problem run "git am --resolved".
If you would prefer to skip this patch, instead run "git am --skip".
To restore the original branch and stop patching run "git am --abort".
I am trying to manually merge the conflicts using:
git mergetool --tool=meld
But I am getting:
No files need merging
How can I solve this problem?
I am getting the name of the file which holds the error, but have no idea about the line (it's a big file)
Maybe there is a better way to perform such patching?
I'm in charge of handling all patching at my work. I've had this happen many times. A patch cannot be merged. The reason this is happening is because the master branch has changes that the patch did not take into account, which prevents it from patching correctly. From all my experience, this could be caused by several things:
The person who made the patch failed to pull the master branch and rebase master onto their development branch.
Between the time that the person pulled and the patch was applied enough changes were made to the master branch to stop the patch from applying due to too many conflicts.
The person patched incorrectly.
Here is the flow I've had the most success with. (This is assuming the person is developing on a branch other than master)
Make sure you've added all files and commited all changes.
git checkout master
git pull
git checkout {development branch}
git rebase master (this will bring the development branch up to speed with master)
git checkout -b {submission branch} master
git merge --squash --no-commit {development branch}
git commit -am "Commit Comment Here" (NOTE: This commit comment will be the name of the patch)
git format-patch origin..HEAD
That makes sure your patch is up to date with the origin master branch. Send that patch and hopefully the patch is applied before too many changes are made on the master.
You need to do a 3-way merge:
git am -3 0001-someFile.patch
git mergetool -t meld
Here is the scenario:
On a smallish Ubuntu web server I have a git server running. The website is checked out from git repository. I had a bulk of changes that I added and committed. Git diff showed 50+ code files updated and 20000+ image files. I did not paid much attention to this thinking these should be ignored, my fault. A bit stupid but I thought it was quickest to just commit all changes as a bulk. Let's call it commit A
# Commit A
git add .
git commit -m "Changes so far in this year"
I discovered that I forgot to exclude working/output files (huge number of generated images). Other than these files (around 20000) I had about 50+ files with code changes.
After reading online and git manual I understood that best bet was to update .gitignore and generate a list of files to remove and remove cached. This should remove from commit but not the local folder. Let this be commit B
# Commit B
vi .gitignore
git ls-files -ci --exclude-standard -z | xargs -0 git rm --cached
git add .
git commit -m "Cleanup of generated files from commit history"
Trouble is that now my git push fails with following error
git push origin master
Counting objects: 19219, done.
error: pack-objects died of signal 9
error: pack-objects died with strange error
error: child process died of signal 9
error: died of signal 9
error: failed to push some refs to '/srv/gitrepositories/xxxx.git'
Answers on this question about error 9 suggests it might be due to git running out of memory.
My options?
Is commit A & commit B made up of huge
number of objects, which looking at the count above it seems?
Is there a better way to clean this mess up with possible option to remove commit A & commit B altogether from history and get my changes intact?
Idealy I want to go back to stage where my git diff reports only the 50+ code files. Images are now ignored by .gitignore
Can I delete a git commit but keep the changes? Is this what it sounds like? Can I do it twice for both commit A and commit B?
Yes, you can use git reset HEAD~2 to clear the last 2 commit from history permanently while keeping the changes in the working directory, then git push -f to force push your changed history to the remote.
If your repo is shared with others it's not advisable to change your commit history.