I have a new mac. I've copied all of my files from my old computer into my new one, including my code base which happens to be slightly more up-to-date than what's on my github repo (I didn't do a final commit beforehand). Basically, I'm trying to pick up where I left off - link my current, more up-to-date code base on my new computer with my existing github repo, then push the new code to it and carry on with my work (it's only me on this repo). I figured this would be as simple as git init
followed by setting git remote add origin [email protected]:me/myproject.git
, but that doesn't seem to be working. How might I go about doing this?
First of all, clone the repo to your new system and then initialize it. Once done this change to that directory and copy or reapply the changes to the cloned repo and then add to it. $ git add . After that commit and push the changes to the remote repo.
I've copied all of my files from my old computer into my new one, including my code base which happens to be slightly more up-to-date than what's on my github repo (I didn't do a final commit beforehand).
You shouldn't have had to do anything.
If you copied your whole code base, including the .git/
directory contained within it, then you could just continue from where you left off. git commit
and git push
as normal. Git comes with OS X, and you have all the code and repository; the .git
directory is the repository.
What you might have to do is make sure your Github ssh keys are set up, and any supporting software for your project is installed. But as far as git is concerned, you're ready to go.
I figured this would be as simple as
git init
followed by settinggit remote add origin [email protected]:me/myproject.git
Fortunately a git init
on an existing repo is harmless. So is trying to add a remote that already exists, you should have gotten an error like fatal: remote origin already exists.
That's fine, your repository already has a remote. Check with git remote -v
.
Another approach is, since you have your code base copied in a folder:
git clone
your GitHub repo in another folder,add your modified files in that repo from your codebase folder:
cd /path/to/cloned/repo
git -C /path/to/copied/codebase add -A
Git will detect the new/removed or modified files and add them to your index.
It is more efficient than trying to copy your codebase into a cloned repo, as it takes into account deleted files.
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