How to migrate GIT repository from one server to a new one
To add the new repo location,
git remote add new_repo_name new_repo_url
Then push the content to the new location
git push new_repo_name master
Finally remove the old one
git remote rm origin
After that you can do what bdonlan said and edit the.git/config file to change the new_repo_name to origin. If you don't remove the origin (original remote repository), you can simply just push changes to the new repo with
git push new_repo_name master
Moving Git repository content to another repository preserving history
I think the commands you are looking for are:
cd repo2
git checkout master
git remote add r1remote **url-of-repo1**
git fetch r1remote
git merge r1remote/master --allow-unrelated-histories
git remote rm r1remote
After that repo2/master
will contain everything from repo2/master
and repo1/master
, and will also have the history of both of them.
Migrating a GIT Repository to the Cloud
For Github:
Create new repository in Github and don't create a readme file.
Clone the mentioned repository from your server to your local machine.
git remote add origin <url>
(url of the new github repo)git push origin master
Note: you shouldn't commit because you probably already have commits in this repository, just add a new remote I called it origin and push it to the Github server
Git push existing repo to a new and different remote repo server?
- Create a new repo at github.
- Clone the repo from fedorahosted to your local machine.
git remote rename origin upstream
git remote add origin URL_TO_GITHUB_REPO
git push origin master
Now you can work with it just like any other github repo. To pull in patches from upstream, simply run git pull upstream master && git push origin master
.
How to move a git repository into another directory and make that directory a git repository?
It's very simple. Git doesn't care about what's the name of its directory. It only cares what's inside. So you can simply do:
# copy the directory into newrepo dir that exists already (else create it)
$ cp -r gitrepo1 newrepo
# remove .git from old repo to delete all history and anything git from it
$ rm -rf gitrepo1/.git
Note that the copy is quite expensive if the repository is large and with a long history. You can avoid it easily too:
# move the directory instead
$ mv gitrepo1 newrepo
# make a copy of the latest version
# Either:
$ mkdir gitrepo1; cp -r newrepo/* gitrepo1/ # doesn't copy .gitignore (and other hidden files)
# Or:
$ git clone --depth 1 newrepo gitrepo1; rm -rf gitrepo1/.git
# Or (look further here: http://stackoverflow.com/q/1209999/912144)
$ git archive --format=tar --remote=<repository URL> HEAD | tar xf -
Once you create newrepo
, the destination to put gitrepo1
could be anywhere, even inside newrepo
if you want it. It doesn't change the procedure, just the path you are writing gitrepo1
back.
Git: move existing repository from PC to server, clone from server
On the Linux server, in a new directory do:
git init --shared --bare
Then on your local machine:
git remote add origin server:path/to/repo
git push --all origin
After that, the server will have a full copy of the repository, and you will be able to push and pull to and from it. There's no need to check out another clone from the server when you've already got one locally.
How do I move my local Git repository to a remote Git repository
On your server create the git repositories as bare repository
git init --bare repo.git
then, push the commits of your local repository
git push --mirror ssh://yourserver/~/repo.git
Related Topics
How to Find Out The User of Parent Shell Inside a Child Shell
Quickest Way to Select/Copy Lines Containing String from Huge Txt.Gz File
How to Handle Sigsegv Signal in Userspace Using Rust
How to Concatenate Svg Files Lengthwise from Linux Command Line
What's The Meaning of This Sed Command? Sed 's%^.*/%%'
Can Not Add New User in Docker Container with Mounted /Etc/Passwd and /Etc/Shadow
PHPmyadmin, Neginx Error.Log - Check Group Www-Data Has Read Access and Open_Basedir
What Does Signal(Sigchld, Sig_Dfl); Mean
Detect If Something Is Modified in Directory, and If So, Backup - Otherwise Do Nothing
Kernel Module Build Fails: Sys/Types.H: No Such File or Directory
Why Does High-Memory Not Exist for 64-Bit Cpu
Ftrace: Only Print Output of Trace_Printk()
Kaggle API Issue "Could Not Find Kaggle.JSON. Make Sure It's Located In......"
How to Schedule a Cron for The First Thursday of Every Month
Linux: Triggering Shell Command on File Save
What Is The Minimal Nesesary File Subset, Required to Amd Opencl Work on Linux
Process-Local Override of Name Resolution
Amazon Ses on Google Cloud Computing Instance Vm Using Postfix