How to re-connect a local github repository I completely overwrote? - github

I have a Unity project that I messed up badly, so I downloaded the zip file of the latest repository I pushed to GitHub, deleted the local files, and dumped the content of that zip in place of the old directory. I thought this would be a seamless transition, but now GitHub Desktop is not recognizing these files as a git repository. I don't know why because there are github-specific files in there. I have made significant changes that I need to save. How do I reconnect this repository? Do I want to hit "Clone Again" or will that overwrite what I have locally with what is in the cloud? Again, I want to push what I have locally to the cloud.

For anybody else having this problem, here is what I did:
Save your local repository into a zip file someplace accessible,
like your desktop.
Completely gut your local directory--delete all
contents within the root folder. GitHub Desktop demands a clear folder to clone into.
In GitHub Desktop, where it says it
can't find your repository anymore, click the button that says
"Clone Again". This will download your cloud repository into your
local directory--the opposite of what we wanted, but at least what
comes next will work.
Delete all the cloned files that are NOT files associated with GitHub. This will prevent extraneous files from being left over when you overwrite your project files.
Copy all the non-GitHub-related files from the zip into the renewed directory.
This will restore the link between directories. Now, IT IS POSSIBLE that I deleted an essential GitHub file and did not notice (since there are at least 4 of them), and simply restoring THAT file from the cloud would fix everything. If you become disconnected like I was, I recommend trying that first in case it works and saves you time. Those are the files that get overwritten by GitHub when local files are updated.

Related

What is the difference between uploading and cloning?

I am new to Github and I do not understand what is the difference between uploading directly a file from your computer by dragging it (Upload files option) and uploading through clone with SSH.
Is the first option just regular file uploader and the second an option that connects your repository with your local environment?
The reason for asking this is that I am trying to upload a .ipynb file but I do not want changes done in my local computer to affect the file I have uploaded. Is that possible?
Thank you in advance.
The drag 'n' drop option on the GitHub website it just a 'shortcut' for committing a newly added file in your (local) repository and then pushing it. After you released your left mouse button and the file is uploaded, the web interface even asks you to enter your commit message and the branch you want to push to.
Once you've uploaded the file via the website, the file on your computer has no relation to the file within GitHub, so changes are not reflected.
But even if you clone, local changes and even commits won't be reflected on GitHub, until you do git push.

Deleteing a repository in Visual Studio Code

where can I find .git folder to delete a repo on my system. I opened my local disk as a repository and I have about 5k changes to make.The thing is if I check my git account my local disk is not showing as a repo so i really dont know what is going on. Any solution will be welcomed.
Among the "5k changes", select a file and open it in your file browser. Enable hidden files/folders. Start moving up the hierarchy of that path, i.e., keeping going up in the parent directory of the file.
You'll find the .git folder somewhere. Check its creation date. If it's recent, delete it. Be careful not to delete any commits you had made in some project.

Add files to local repository in GitKraken

Am new to GiKraken.
I have created a local repo and remote (origin) repo.
I have added some files to the local repo (folder on my computer).
But, Gitkraken cannot find them automatically and then cannot commit.
How to add them in GiKraken manually ?
(could not find the way to do it, even "Stage" is not shown inthe community version).
A click on 1 shows your unstaged changes in area 2. The green symbol below 2 indicates a file that was added and is not yet added to your git repository. If you click on it, it will move to the Staged files area and be ready to be commited.
I'm not sure I understand your question correctly. You can not create files in GitKraken, it just manages your existing files in your repository.
If you create or copy files in your repositorys' folder (via file manager or editor or by whatever means), GitKraken will know and show the files as new files in th "Unstaged Files" section, allowing to add and commit them to your repository.

Github Mac App How To Change Default Storage Directory

In the github mac app i am trying to change the default directory of one of my repo's. In the settings screen I only see a place to change the remote repo.
Where do I need to go to change the default location? Sorry if it is very obvious.
So after some trial and error I figured out how to change the location after you have set it up. Apparently it is as easy as just moving the folder that contains the .git. So for example I just moved the website folder into a new directory and the GitHub app was able to track the movement.
Edit 1: The move does not always stick so you might have to try a couple of times.
You manage the local destination of each remote repository you clone at the moment of cloning.
As soon as you click the Clone in Desktop button on a repository's page (on github.com), GitHub for Mac should open up (assuming you've configured the app to be opened up when Clone in Desktop is clicked). When the app opens it first prompts you to choose the location for cloning the repo (cloning means downloading or copying the files). This prompt is where you set the default location for this particular repository on your local machine.
In the interest of users who came here with the same doubt, let me post also my experience.
I wanted to move the GitHub local folders away from the "Documents" folder to free up iCloud space, and because I really didn't need yet another copy of the codes in addition to the one in my machine and in the GitHub servers. That is how I landed in this page in the first place. So I simply moved the folders to a local folder that is not synchronised with iCloud and when I opened GitHub Desktop to confirm if things were working, the app told me "Couldn't local [repository X]." They had a "Locate..." button, which I used to let the app know where the new location was. And I did this for all of my locally cloned repos. That's it, works like a charm now. If you have a lot of repos cloned locally, it might be a one-time hassle to do this, but there's no further action.

How do I change my local directory in eclipse to work with git?

Long story short I moved my local project to the root of my web server. In doing so I've lost my connection to the local git files.
Here is the location of my Working Directory after pulling the source down from git.
C:\Users\Administrator\git\SiteName
subfolders are:
.git
android
website
My local webserver no longer has an android or website dierctory, but instead the contents of website are simply in htdocs.
Is it possible to reference the structure on github but keep my local files in eclipse in a different area, so I can once again merge and push files?
You can tell EGit to point to a local git repo from the Git Repositories view. Once EGit knows where your repo is, it can import projects from that repo. You can work on them in eclipse, but they point to the repo external to the workspace.
You could create symlinks to the files in the "website" directory inside your htdocs. That may or may not be what you want, since, all changes will be immediately reflected on the front end.
While importing a project, eclipse allows you to create symlinks to the files without copying them into the workspace. It's an option that appears after you click the "Advanced" button in the import dialog box. This should allow you to keep the files wherever you like, and still use them in eclipse.