16

I created a new Repository (named repoN) with the existing one (named repoE), simply by copying code from the branch (named B22).

After that, I created a new branch in repoN (named BR01). Now I made some changes in the branch (named BR01) which exist in repoN repository.

I just want to take all those changes into the old repository repoE without loosing history of BR01 into B22.

I am using SourceTree because I'm new in Git and don't know much commands.

Adnan
  • 2,931
  • 3
  • 23
  • 35
user2380509
  • 161
  • 1
  • 1
  • 7
  • 2
    @Adnan: Have a look at [this Meta question](http://meta.stackoverflow.com/questions/327171/user-adding-excessive-bolding-in-otherwise-good-edits) about adding bold fonts. (tl;dr: please don't do it.) – Alan Moore Jun 30 '16 at 16:31

3 Answers3

29
  1. stand on your current repo you want to push from
  2. checkout the branch you want to push
  3. git remote add repoRemote https://bitbucket/repo/repo1.git
  4. git push repoRemote -- will push your current branch to the remote repo you added in #3
Pablo
  • 13,271
  • 4
  • 39
  • 59
Smart Coder
  • 1,435
  • 19
  • 19
  • 1
    Do we need to remove the destination repo with git remote remove repoRemote(not sure if the command is right) to switch to the existing repo once branch is transferred? – coderunner Feb 11 '21 at 10:20
12

At first you need to add to git your destination repository, lets call it repoE ( set remote tracking )

git remote set-url repoE https://github.com/USERNAME/repoE.git

then switch to branch your want to push, assume your branch called BR01

git checkout BR01

and push this branch to destination repository

git push repoE BR01
Maksym Semenykhin
  • 1,924
  • 15
  • 26
1

In SourceTree, it can be done by adding repoE to Repository->Add Remote so that you can push the changes in repoN to that repo.