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.
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 .
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.
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.
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.
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.
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?
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:
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.
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)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With