Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

A complete backup of a git branch

Tags:

git

What is the best way to backup a complete branch from a local git repository on one PC with the purpose of adding it to a local git repository on another PC.

In the case where the remote git repository server is offline due to failures on their end.

like image 676
Knossos Avatar asked Nov 19 '14 08:11

Knossos


People also ask

How do I backup a github branch?

To do this you need three steps: Make an empty backup repository on the external backup disk; Point your current git repository at the backup repository with git remote add ; Send the changes to the backup repository with git push .

How do I clone a branch?

In order to clone a specific branch, you have to execute “git branch” with the “-b” and specify the branch you want to clone. $ git clone -b dev https://github.com/username/project.git Cloning into 'project'... remote: Enumerating objects: 813, done.

How do I backup a folder in git?

You can backup every file in your git repository by doing the normal git clone <git-url. git> command. By doing that, you download every file in your repository with their actual size and you can do git workflow in it. It's basically the usual way to clone a git repository.

How do I backup my entire Git repository?

The correct answer IMO is git clone --mirror. This will fully backup your repo. Git clone mirror will clone the entire repository, notes, heads, refs, etc. and is typically used to copy an entire repository to a new git server.

How to create a temporary branch using Git backup?

BACKUPED! Copy backup nameed directory to original named directory. Create temporary branch and push it. git branch command creates "like" a copy of current branch.

What is Git backup and how does it work?

Speaking of Git, backup is not that straightforward thing. One of its primary functions is clone. As you probably know, clone allows you to … clone a repository, which means creating a local, fully functional copy. But what does this feature actually do?

What does git-branch-backup do?

git-branch-backup Creates a local backup of your branch. Usefull to do before git-rebase in case it goes wrong so you do not have to go reflog diving. Assuming you are standing on master:


2 Answers

First, you can make a local clone of your current repo, including only your branch:

git clone -b mybranch --single-branch /path/to/your/local/repo.git

Then you can make a bundle of that repo, in order to easily save it (a bundle is a Git repo, compressed into one file).

If you have the possibility to make a bare empty repo somewhere accessible (even through a simple shared folder), you could simply push your branch to it.

like image 150
VonC Avatar answered Oct 24 '22 15:10

VonC


as oneliner for per minute backup ... ( this will bloat your git branch -a )

 git branch $(git rev-parse --abbrev-ref HEAD)--$(date "+%Y%m%d_%H%M") && git branch -a | grep -i $(git rev-parse --abbrev-ref HEAD)

which is actually a 2 liner:

git branch $(git rev-parse --abbrev-ref HEAD)--$(date "+%Y%m%d_%H%M");
git branch -a | grep -i $(git rev-parse --abbrev-ref HEAD)
like image 30
Yordan Georgiev Avatar answered Oct 24 '22 15:10

Yordan Georgiev