Suppose I have a branch called test on remote server. All of the people working with this repository have this branch too. We all make some local commits to it and somehow the remote version becomes changed. Now, I want to merge remote named branch test into my local branch test having my current work saved. So if my current branch is default I do:
hg update -C test
make some changes in test branch
hg commit -m "Some changes"
hg pull
hg merge
hg commit -m "Merge"
hg push
However I recieve strange error during some of those steps: abort: branch 'test' has one head - please merge with an explicit rev
(run 'hg heads' to see all heads)
Why is that?
Related
I'm not used to git and I'm starting to learn it but I got stuck in pushing the changes into one branch 'Master'.
In github I see that I have 2 branches: Main and Master, after making my changes and afterward I ran the following commands:
-git add .
-git commit -m 'Commit-text'
-git push origin master
And everything is fine since on github I can see the changes but only in the branch 'Master' while the branch 'Main' doesn't result changed. How can I solve this issue?
You can simply solve this problem by going to Git Bash and renaming your main branch:
$ git branch -M [NAME_BRANCH]
so in your case:
$ git branch -M main
GitHub has recently taken the decision to rename its main branches from master to main. So "master" is expected to fall into disuse in the next few years.
So what I recommend, whenever you start a new project on Git, is to always rename the main branch from the beginning.
So when you push your code, you can safely use only one main branch using the following code: $ git push origin main
I have a forked project, and now the master repository has added a new branch which I want on my forked project.
Is it best practice to add the branch locally and then merge from the master repository, or is there a more correct way of doing this?
My guess is this, but I don't want to mess things up:
hg branch theNewBranch
hg pull -r theNewBranch ssh://hg#bitbucket.org/master_repository/theproject
hg merge 0011223344ff
hg commit -m "Merged in master repository branch"
There's no need to add it locally. Every commit has the branch it is on burned into it. If they have a commit on theNewBranch you'll get it.
If you want everything they have mirrored locally just do:
hg pull ssh://hg#bitbucket.org/master_repository/theproject
And if you want to merge in into your local branch do:
hg checkout mylocalbranch
hg merge theNewBranch
I have the branch name default which is my production branch. Now I want to create development branch from there and work separate on it.
How can I do that without affecting my default branch
Commit or shelve all your current changes, then:
hg branch Name_Of_Branch
This will switch your working code to a branch called *Name_Of_Branch* - N.B. this branch will not exist in the local repository until you do a hg commit and will not exist for anybody else until you have done a hg push, (or an accepted pull request to an administrator), and they have done hg pull.
I am currently making a project in eclipse.I made changes in head branch and as well as in master branch.I want to merge those changes and push them to remote repository.Please tell me the correct steps so i merge both branches and push the changes to remote repository without getting non fast forward warning.
I am currently making a project in eclipse.I made changes in head branch and as well as
in master branch.
Normally when people refer to "head" they are talking about HEAD, which is not actually a branch but a reference to the "tip" of the currently checked out branch. So if you
git clone foo
cd foo
git checkout bar
assuming bar is a branch, then HEAD would refer to the "tip" or last commit of the bar branch.
If you are getting a non fast forward warning on a push, changes have been made to the remote repository. You to bring those changes into your local branch before you can push.
This is because git requires merge conflicts be resolved in the local repository, not the (usually shared) remote repository. To bring those changes to your local repository you will need to execute a pair of commands; git fetch ... and git merge ... results in a merge commit, which some prefer -- while git fetch ... and git rebase ... if merging the changes without a merge commit is preferred. Note that git pull ... is the same as git fetch ... and git merge ... and git pull --rebase ... is the same as git fetch ... and git rebase ....
Which ever way your prefer, once you get the changes to your local repository (and resolve any conflicts there may be) you will be ready to push.
I cloned the centeral repository via
hg clone my_project my_project_1
then after switching to a newly created repo I marked as a new branch
hg branch v1
While inside the new clone I issued
hg ci -m "branch created"
but when I tried to push the changes back to the original repository I cloned from
I got this error:
abort: push creates new remote branches: v1!
How do I push the branch into the original repository?
Am I doing the right thing by trying to push the branch into the original repo? I just want to have a centralized repository which would contain branches and from which I would be able to check out branches.
What's the best way to deal with this problem?
Thank you.
It depends on the version of Mercurial that you're using. The command used to be hg push -f ... or hg push --force ... to force the creation of a new branch in the remote repository (which is usually OK).
However, using -f also allows you to create new heads in the remote repository (usually not OK), so current versions of Mercurial (1.6 and above) have a --new-branch option to hg push that allows you to create a branch, but not create a new head, so the command is:
hg push --new-branch
You can also limit pushes to just the branch that you're working on with the -b flag, so:
hg push --new-branch -b v1