Any tools to merge 2 git repos? [duplicate] - merge

This question already has answers here:
How do you merge two Git repositories?
(26 answers)
Closed 4 years ago.
I am trying to merge 2 gitlab repos with all history but failing. Are there any gui tools or script to achieve it?
Since this is going to be a ongoing activity I am looking for something easier way

Just use the existing tools provided by git:
You can register one of your repos as origin and one as upstream...
git remote set-url origin git#xxx...
git remote set-url upstream git#xxx...
...then you can merge your changes from one repo into the other by first checking out your origin...
git checkout -b mybranch origin/mybranch
...and then merging your upstream into your local branch
git merge upstream/somebranch
... then pushing back into your origin
git push origin mybranch
Hope this helps

Related

How do I get rid of all the previous 'merge masters' in my Pull Request on Github?

Whenever I make a pull request on Github, in the commit tree it shows tons of previous commits that were made starting 13 days ago. How do I get rid of all that?
My git flow is usually:
git pull master
git checkout -b "another branch"
git add
git commit -m "message"
git push origin master
If, while checked out on another branch, you run git rebase master, another branch will essentially become the most recent master plus all the commits you have added to another branch since you created it.
I would recommend reading a short tutorial about rebasing if you haven't done it before.

Git merge conflicts,unable to push or pull code from master [duplicate]

This question already has answers here:
How do I resolve merge conflicts in a Git repository?
(36 answers)
Closed 2 years ago.
I’m stuck at this point where me and my teammate working on the master branch and we both pushed the code but I didn’t pull the changes and again pushed the code so here i’m now I can’t pull or push the code.. what should i do?
This might look intimidating but bare with me:
Get the hash of the stable common commit between you and master: git log
Soft reset your commits to convert them to unstaged changes.
: git reset --soft [hash]
Stash you current working changes: git stash
Fetch latest changes from remote: git fetch
Pull latest changes from remote: git pull
Bring back your work from the stash: git stash apply or git stash pop
Resolve any conflicts and recommit your work: git commit ...
Push your changes to remote: git push
From now own, you should remember to do all your work on a separate branch and then merge them onto master.
Checkout a new branch.
git checkout -b tmp
Delete your current master.
git branch -D master
Checkout master from origin
git checkout master
Merge your branch and handle conflicts
git merge tmp

Sync my fork with the original repo on github? [duplicate]

This question already has answers here:
Merge changes from remote github repository to your local repository
(4 answers)
Closed 7 years ago.
I have forked a repo on my github. And I also cloned my fork on my desktop like this
git clone myfork.git
and did some commits. How do I keep my fork in sync with the the original repo with my latest commits?
After you commit, you should git fetch upstream, which will get the changes from the parent repository. After this, you should git checkout master, which will move you back to your fork's master branch. The parent repository's changes are held in the upstream/master branch, so you can git merge upstream/master to merge the parent repository's changes into your current fork. This will update your repository, and repeat whenever you want to pull the latest changes from the parent repository.
As stated in the comments, you can use https://help.github.com/articles/syncing-a-fork/ for more help.
Since you already cloned the repository. Now, add your original repository, for convention lets name it original repository. Same as above, Copy-URL of your authors original repository
git remote add original COPY-URL
If you successfully added the remote repository. Now lets fetch that, we are actually pullinig the original here:
git fetch original
Since we fetched the original. Lets merge them
git merge
git merge original/master
How do I update a GitHub forked repository?
You can refer here for more details:

How to keep forked version of github sycned

I've forked a version of this
https://github.com/googlesamples/android-topeka
a few days ago.
I'm making changes to it in Android Studio. Now changes have been committed to the original project at
https://github.com/googlesamples/android-topeka
I want to merge my changes I've been making locally with that version. But at the same time I want to keep my version private?
How can I COMPARE my changes locally with the master?
Typically, your workflow in GitHub will go something like this:
git pull origin master
# work work work
git commit -m 'I made some changes to android-topeka'
git pull origin master
# resolve merge conflicts
git push origin master
The general strategy is to commit your local changes, then git pull the remote to bring in any changes which other developers might have made to the android-topeka repository since you last pulled. Once you have resolved the merge conflicts (if any), then you can fast-forward the branch on GitHub by doing a git push.
Note that origin points to https://github.com/googlesamples/android-topeka in your case. I also assume that your local branch is called master, as I only see one master branch under the android-topeka project on GitHub.

Are remote branches cloned to local git repo? [duplicate]

This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
Partial clone with Git and Mercurial
If I only want to clone one branch, how can I do that?
Does git clone url mean git clone url --all?
[hugemeow#home base]$ git branch
* master
[hugemeow#home base]$ git branch -a
* master
remotes/origin/HEAD -> origin/master
remotes/origin/donut-release
remotes/origin/donut-release2
remotes/origin/eclair-passion-release
remotes/origin/eclair-release
remotes/origin/eclair-sholes-release
remotes/origin/eclair-sholes-release2
remotes/origin/froyo
remotes/origin/froyo-release
remotes/origin/gingerbread
remotes/origin/gingerbread-mr4-release
remotes/origin/gingerbread-release
remotes/origin/ics-factoryrom-2-release
remotes/origin/ics-mr0
remotes/origin/ics-mr0-release
remotes/origin/ics-mr1
remotes/origin/ics-mr1-release
remotes/origin/ics-plus-aosp
remotes/origin/jb-dev
remotes/origin/jb-mr0-release
remotes/origin/jb-release
remotes/origin/master
remotes/origin/tools_r20
[mirror#home base]$ git branch -r
origin/HEAD -> origin/master
origin/donut-release
origin/donut-release2
origin/eclair-passion-release
origin/eclair-release
origin/eclair-sholes-release
origin/eclair-sholes-release2
origin/froyo
origin/froyo-release
origin/gingerbread
origin/gingerbread-mr4-release
origin/gingerbread-release
origin/ics-factoryrom-2-release
origin/ics-mr0
origin/ics-mr0-release
origin/ics-mr1
origin/ics-mr1-release
origin/ics-plus-aosp
origin/jb-dev
origin/jb-mr0-release
origin/jb-release
origin/master
origin/tools_r20
Edit 1
In fact my issue is not the same as Clone only one branch, though the answer may be a bit similar ...
By the way, if that link is the solution, how can I get the list of branches before I cloned it from the remote repo? (This issue is not mentioned in that link, and if that link could answer my question, this issue should be pre-solved.)
You can get a list of branches before clone with git ls-remote --heads <repo-url>.