Step 1: Git clone all remote branches locally

for branch in `git branch -a | grep remotes | grep -v HEAD | grep -v master `; do
   git branch --track ${branch#remotes/origin/} $branch


# Now we have to have all remote branches locally.

Step 2. Add a “new repo” as a new remote origin:

git remote add new-origin

Step 3. Push all local branches and tags to a “new repo”.

# Push all local branches (note we’re pushing to new-origin):

git push --all new-origin

# Push all tags: 

git push --tags new-origin

Step 4. Remove “old repo” origin and its dependencies.

# View existing remotes (you’ll see 2 remotes for both fetch and push)

git remote -v

# Remove “old repo” remote: 

git remote rm origin

# Rename “new repo” remote into just ‘origin’: 

git remote rename new-origin origin
Posted by:Rahul Kumar

Rahul Kumar working as a Technical lead at Bangalore, India. He has more than 5 years of experience in distributed system design with Java, Scala, Akka toolkit & Play Framework. He developed various real-time data analytics applications using Apache Hadoop, Mesos ecosystem projects, and Apache Spark. He loves to design products around big data and with high velocity streaming data. He had given a couple of talks on Apache Spark, Reactive system and Actor Model in LinuxCon North America, Cassandra summit & Apache Bigdata Summits.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s