Git Pushes New Branch With Master Content
I migrate a repo from mercurial to git through:
git init gitrepo
cd gitrepo
hg_fastexport -r <../hgclone>
(I hope I didn´t forget anything) Then I created in GitLab an repository and in the gitrepo (to where hg-fastexport exported the sources) I created branches and pushed them like
git checkout -b v4.1
git push origin refs/heads/v4.1:refs/heads/v4.1
While this was working with 2 branches, it showed also up in Gitab, the last branch always gets the content of the master branch, not the v4.1 branch.
Answer
I found the error i´ve made. Maybe the problem was not so clear, but when i created a new branch the branch would had always the content of the master. It would contain not the branch. The reason for that was that i´ve forget, after i migrated from mercury to git, to check out the HEAD. It seems as if then i was working either on the master or a branch but while i forgot to checkout the (newly migrated HEAD), the content of the new branch and the master remained the same.
I will give here a receipt which led to a correct repository.
clone the Mercurial directory:
- hg clone http:mercurial.com ./hgclone
Init the git directory:
- git init git-dir
cd git-dir
migrate mercurial to git: hg-fast-export -r ../hgclone
- git checkout HEAD
- Add git repository: git remote add origin $remoterepo
- Add current dir: git add .
- commit: git commit -m "Initial Commit"
- push: git push -u origin master
List the branches for to create and update them to the remote git-directory - git branch
checkout and add the branches to the remote git directory:
- git checkout branch
- git add .
- git push origin refs/heads/branch:refs/heads/branch
This are the fundamental steps which worked for me for exporting a mercurial repository to git and store them with the right branches to the remote git repository.
Related Questions
- → Authenticate with a cookie using laravel 5.1 and jwt
- → Finding a specific GitLab tag from PHP
- → React: How to publish page on server using React-starter-kit
- → babel-loader, webpack, ES2015 modules: "Element type is invalid"
- → Create a function-attribute of a function, which is, in its turn, a method of an object literal
- → Model Validation in laravel 5.1 not working
- → GIT fatal: loose object
- → Laravel validation required rule not working
- → Axios array map callback
- → Where does this `webpack://` come from for `webpack-dev-middleware`?
- → error when trying to modify project in laravel forge
- → GitHub Pages and Jekyll content duplication and SEO issues
- → Use Laravel repositories with Datatables