“git how to switch to another repository” Code Answer's Create a new repo at github. Clone the repo from fedorahosted to your local machine. Now you can work with it just like any other github repo. simply run git pull upstream master && git push origin master.
To change this current working directory, you can use the "cd" command (where "cd" stands for "change directory").
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.
It's even simpler than that. Just did this (on Windows, but it should work on other OS):
Git just sees you added a directory and renamed a bunch of files. No biggie.
I am no expert, but I copy the .git folder to a new folder, then invoke: git reset --hard
To do this without any headache:
git status
, let's say branch "development".git clone
the project from repository.git checkout development
.rsync
, excluding .git folder: rsync -azv --exclude '.git' gitrepo1 newrepo/gitrepo1
. You don't have to do this with rsync
of course, but it does it so smooth.You are good to continue exactly where you left off: your older branch, unstaged changes, etc.
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