I have a project with a simple local git repo, and I want to move this project (folders etc.) to another computer and work from there from now on. I don't want to have anything left on the old machine (except of course my other git projects). I want it to be as if I have been working from the new machine all along.
Can I simply move all the files over to that computer, or will there be a problem with keys? Should I have the same key across two machines? If simply moving all the folders can't be done, what should I do? I want to avoid the hassle of setting up and learning to use a server, since this seems complicated and I don't want to alter my workflow.
Thanks. Yes you can, but there's no need to copy the full working tree. You can copy just the . git folder without the working tree (i.e. as a "bare" repo) and then checkout the latest working tree on the other machine.
You need to clone the repository on your second computer. Now you can use git pull and git push to keep your local repository in sync with the one on GitHub. Show activity on this post. You want to checkout the repository on the other computer, you do not want to fork it.
For your case, the best way to do it is to copy over the folder (copy, scp, cp, robocopy - whichever) to the new computer and delete the old folder.
I completely disagree with @Pablo Santa Cruz that cloning is the paradigm for what you are doing. No it is not. You are moving a repo to a new computer.
Why I don't like clone for this purpose:
If you search for ways to backup a git repo, git clone wouldn't be in the top answers. So it shouldn't be used for moving a repo! I also feel that just a git clone
cannot be a proper answer because git clone
has the --mirror
option, which preserves the repo, meaning that a git clone
repo is different from git clone --mirror
repo (apart from being bare, the differences are mostly those I mentioned above). I would do a copy because I know what I get with the copied repo - the same repo!
When to consider git clone:
Yes it's enough to copy the data to the other machine. Using git clone is almost the same thing, but it will setup the computer you are cloning from as the remote origin, which might not be what you want.
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