I'm just starting working with Mercurial and Tortoise HG. I've created two uncoupled changes, one is a bug fix and one is a new experimental feature.
What is the best way to set this up (using bookmarks, tags or branches or something else) so that I can commit both but push only one of the groups of changesets to the remote repository.
And can this be done easily in Tortoise HG or is command line knowledge of mercurial required?
You can do this from both the CLI and from TortoiseHg. Note that using bookmarks, tag, etc.. has no influence on what you can push.
Using TortoiseHg v1.X.X
Identify the outgoing changesets and then right-click on the head of the branch you'd like to push and select push this branch.
Using TortoiseHg v2.X.X
You must first configure the tool to allow pushing new named branches by clicking Options and selecting the following:
Using the Target option in the Synchronize view, select the branch you want to share and perform the push. This will only share the selected branch. Unchecking Target will cause every new changeset to be pushed.
Related
Using tfs2015 (not git but tfvc)
We have a MAIN branch and I created my development branch from MAIN branch.
__MAIN (branch)
|__MYDEV (my new branch)
After a while, my friends pushed 2 new changesets to MAIN.
__MAIN [change1], [change2]
|__MYDEV [mychange1]
Question: How can I get those 2 changesets onto MYDEV branch as 2 changesets as they are by merging (rebasing) my change on their changes?
If I try merging MAIN onto MYDEV, 2 changesets are coming as pending changes of bunch of files, but I want them as they are as packaged in 2 changesets and put my changes on them.
Finally what I expect,
__MAIN [change1], [change2]
|__MYDEV [change1], [change2], [mychange1-with-merge-fixes]
If you use git-tfs it will give you all the powers of git, highly recommended. Now, visual studio will maybe be a little bit upset when it detects a .git directory, but you can avoid that by setting GIT_DIR and GIT_WORK_TREE environmental variables (see this answer for details).
You can use "Rebase" tool to keep every merged changeset separately in the branch.
To use rebase tool in TFS, follow the steps below if you have Team Explorer installed:
Launch Team Explorer and connect to your project.
Open "Branches".
Checkout the branch (MYDEV) you'd like to rebase.
Right click the branch and select "Rebase Onto..." option.
Select the Onto Branch (MAIN) and then click "Rebase" button. (Resolve the conflict and click "Continue" button if there is any conflict during the rebasing)
Introduction about TFS Rebase: https://msdn.microsoft.com/en-us/Library/vs/alm/Code/git/rebase
This is probably quite simple, but I am just not familiar with eclipse. I have a dev branch that I have pushed to the server for review using the basic git push origin dev. My co-worker is new to git and would prefer to stay within eclipse to review the code. He has egit installed and I cannot seem to find a way to pull a specific remote branch. I know this is brief but I am more than willing to provide any information for clarification.
To easily review the changes, your co-worker can check out the remote branch as a new local branch and then look at the code and commits.
One possible way is:
Team > Fetch from Upstream to get the newest branches (or a normal pull, which includes a fetch)
Team > Switch to > New Branch...
Select origin/dev (assuming the remote is named origin) as the base branch
Click Finish to check out the new local dev branch
It can also be done via the Git Repositories view by expanding Branches > Remote Tracking and using Create Branch... from the context menu.
Another way is to find the branch in the History view (you may need to toggle the Show All Branches and Tags option, see here) and use Create Branch... there.
I kind of feel I am missing something here, but here is the question.
I have a branch A. Work is in progress in this branch. A tag T is created which marks a production release version. Now, a fix has to be done on top of the code in this tag. So I created a branch B out of the tag. The branch would contain stable production code.
My eclipse points to checked-out code in branch A.
Now, I want to make changes to code in branch B. How can I make my eclipse realize that there are 2 different branches and the code is different?
Do I have to clone the branch B and point a new eclipse workspace to it?
Cant I use the same workspace and have 2 different versions of the same file - one from branch A and another from Branch B?
Just checkout branch B in your workspace, make your changes, commit, and then you can checkout again branch A and continue to work on branch A. Eclipse will automatically recognize the content of the other branch
However, you should be aware, that you shouldn't have uncommitted changes in your workspace, when you checkout another branch. Either commit your changes or stash, before checkout.
assuming you have eclipse integrated with your git system, you can use select the project you are working on, and then in the context menu, use "Team->Switch To->New Branch...", and choose branch B.
if you don't have it integrated, you can do so with the following 2 steps.
using the git perspective, in the Git Repositories view, find the icon with the + to perform Add an existing local Git Repository to this view .
in the subsequent dialog, choose the location of your repository.
once it's added, go back to your java perspective, and from there, select the project in git (which you currently have in branch A), and from the context menu, select Team->Share Project
I am working on some bugs in our code base and I have created separate branches for each bug. I have rebased one of the branches on top of default. I generally use the mercurial plugin for Eclipse and I would do a push (when I am in the default branch). This pushes my changes on the default branch.
I tried to do the same thing with TortoiseHg. When I press push, the client complains that I am about to create remote heads/create new branches on the server. Is there some way to push only changes on one branch using TortoiseHg?
Thanks for your answers!
Here’s another way to do it:
Open Repository Explorer.
Click Determine and mark outgoing changesets (green up arrow button). All your changesets / branches will be marked with an up arrow.
Right-click on the changeset you want to push. From the menu, select Push to here.
Works the same way as the previous answer, but allows you to select the changeset from the list, without typing or pasting the target changeset id.
The easiest way to do this is via the command-line using hg push -r . from the branch with the change you want to push. See hg nudge for details.
That being said, it is also possible via TortoiseHG:
Open your Repository Explorer
Open Tools->Synchronize
Open "Advanced Options"
Set "Target Revision" to the changeset that you want to push
Select "Push"
This should only push the changeset you specified (along with any parents of that changeset which may be required). If you limit the changesets that are pushed to those on your default branch, there should be no warning about creating additional heads.
More information (well, not that much) can be found in the Section 4.9 of the TortoiseHg documentation.
I am trying to contribute to a project that uses Subversion. I used Mercurial and its hgsubversion extension to clone the repo. My work takes place on a feature branch.
How do I keep the feature branch up to date with stuff that happens on the default branch (hg speak) aka the trunk (svn speak)?
So I used hg up feature to update to the feature branch, then hg pull which gave me changesets on the default branch. So I did hg merge default, the committed the merge, then tried hg push to send my changesets to Subversion. And Mercurial said: "Sorry, can't find svn parent of a merge revision."
I have finally figured out how to get my repository un-wedged after an event like that described in the question, so that I can continue work without having to re-clone the parent repository (which is, obviously, a quite slow operation when you are pulling from Subversion!). If the "tip" of Subversion outruns you so that you cannot push any more, just make sure that you have the built-in "rebase" extension activated in your Mercurial through a $HOME/.hgrc line like this:
[extensions]
rebase =
And then you should be able to run this command when your repository gets wedged:
$ hg rebase --svn
If I understand this correctly, it dissolves your current branch that has taken you away from Subversion HEAD, and rebuilds it atop the branch "tip" in Mercurial that corresponds to the HEAD in Subversion. From there, you can keep working and successfully do pushes again. It has always worked for me so far; let me know if you run into any problems!
Mercurial as a few different branching modes: http://stevelosh.com/blog/2009/08/a-guide-to-branching-in-mercurial/
The one you're describing is 'named branches', which is the most popular when you're working with a repo that's accessed only via mercurial (or hg-git).
However, when you're using hg-subversion so that you're pushing changes to/from subversion, which only nominally has branches, you're better off keeping all of your mercurial changes in the 'default' named branch, and using the 'clones and branches' pattern (which I prefer anyway).
Specifically, that message Sorry, can't find svn parent of a merge revision. isn't a descendant of a revision that has a direct match in subversion.
Were I you, I'd reclone from svn, and then move my work into that repo's 'default' branch with the 'transplant' command (packaged extension). If you want multiple features in parallel w/ hg-subversion use separate clones (they're so cheap), as it's more in line with how subversion thinks about branches.
I needed to figure this out for myself and wrote it up here:
http://notebook.3gfp.com/2010/05/pushing-a-new-feature-from-a-mercurial-repo-into-an-svn-repo/
I haven't yet figured out how to close a branch in subversion and have the mercurial graph look correct.