How to recover .git folder deletion? - windows

I accidentally deleted my .git folder, I would like to recover the .git folder, but I permanently deleted it.
Will I lose all my project's history?
I also tryed the following solution with no success.
Notes:
It happened when I imported the code to the Eclipse IDE.
I made many local changes without pushing them.
I also using GitHub as a repo.
Using Windows 10.

If you have pushed your changes to GitHub, then all your history is sitting in the repo on GitHub. You can clone the repo again.
If you have not pushed your changes to a remote repo, then the only place that those changes existed is in your local .git directory in your project directory, and those changes are now gone.

I had to re-clone the repository and paste the .git folder in the recently cloned project, into the project's folder.
So I only lost the local commits.

Related

I cut/pasted a folder into a local repository mid-clone - the clone failed and the folder disappeared. Is the folder I pasted gone forever?

I wanted to put my local code into a GitHub repository.
I created a repo on GitHub and tried cloning with HTTPS.
The clone was taking a moment but the folder was created on my laptop so I decided to cut/paste my local code into the local repo folder.
Well, the clone ended up failing and the repo folder just disappeared, along with all of its contents.
The folder I added to the local repo also disappeared.
I can't even find it in the recycling bin. Is it gone forever?
Next time:
make sure you have installed gh, the GitHub CLI
create a repository locally where your code is
publish to GitHub (that will create the remote repository)
That way, no clone, no hazardous code migration.
The command to create the remote repository is (after a gh auth login):
gh repo create.
Inside a git repository, and with no arguments, gh will automatically create a repository on GitHub on your account for your current directory, using the directory name.

Extra directories and files added to git repository

I had always used Git locally on Mac OSX and decided to try out Github and Bitbucket. I had some issues getting it working and tried a few fixes that others suggested who had similar problems. I was able to push to Github and Bitbucket, but I also managed to somehow add extra directories and files to my repository in the process.
I'm using Xampp to develop locally, and I have a folder in there that I created my repository with, so the file structure is something like this
Applications
XAMPP
xamppfiles
htdocs
myproject -this is was originally the repository that I had been using
randomdirectory1
randomdirectory2
randomdirectory3
randomfile1
randomfile2
One thing to note. Not every single directory and file in htdocs was added to my repository. There were only 3 added, and about 7 other folders.
Prior to trying out github my repository just consisted of myproject located in /Applications/XAMPP/xamppfiles/htdocs/myproject. Now, there are a bunch of other directories and files added to it. I know this, because in conjunction with the command line I also used GitX for a visual reference. Now, all of these extra files and directories are showing up.
Maybe I don't fully understand how git repositories works. Prior to this, I had only used add, commit and checkout commands. All I know is that my repository appears to be different in GitX and matches on Bitbucket/Github.
What folder did you initialize the Git repo from? It sounds like you meant to init from the myproject folder, but instead you did it from the Applications folder.
Does GitHub show all those extra directories?
Where is the hidden .git folder?
Is this a private repo just for you, or just for you and a few known others? Are you willing to rewrite history?

When I try to drag and drop a folder which contains a git repository (which is a submodule at the moment) it says "Can't drop folder here..."

In the git-windows-interface when I drag and drop a repository it says: "Can't drop folder, You can only drop one folder without git repository with the app at this time. Dropping a single folder will allow you create a new Git repository in that location...".
How should I add a git repository to the git-windows-interface?
thanks
You can try and make GitHub for Windows detect your repo, by modifying the local path(s) it scans.
That would avoid trying that "drag and drop feature" which might not work in your case (being a submodule, which is by nature a nested git repo).
If it isn't possible to change that path, at least try and copy that repo in %HOME%\My Documents (HOME being set by the portable git within GitHub for Windows, C:\User\login on W7+, C:\Document and Settings\Login on WXp).
Then a local scan will detect it.
I was getting the same error. I had been trying to drag in the hidden .Git folder. Instead, drag in the folder above, which contains the .Git folder.
This worked for me:
Rename the ".git" folder to ".git_back"
Create a new git repo in the same folder so the new ".git" folder is in the same folder as the old one.
Close github for windows, delete the new .git folder and rename the old one back to ".git"
Open github for windows again, and it will see the old ".git" folder.

Changed folder structure in Xcode Project not reflected in Git Repository

I have an Xcode project that is under version control. I've grouped the classes in the project navigator into folders based on what the classes do (eg. Models, Views, Controllers, etc.). However, these folder structures seem local to my machine and it is not reflected in my own local git repository, or if I do a git pull from another machine, the folders that I've created or organized my classes into don't appear. So, How do you get the changes you make (organizing the classes into folders) to reflect in your local and remote repository?
Try this
# modified, new and deleted files
git add -A
ref
I found that the adding a folder or directory manually inside the local repository to work for me. Create the folder in the repository,git add folder_name/ to actually track and add it to the repo. The files then can be moved into this folder. Depending on how you move it, you may need to do git rm <file_name> and git add </folder_name/file_name>.

How to point gitbox/git to different local directory

Hi guys I have a remote repository cloned locally, Because my new changes have saved it to a different directory (workspaces in eclipse) I want to point git to the workspace directory rather than the other directory, how do I do this? Gitbox doesn't seem to have any options, and I can't see the .git folder
In your WORKSPACE do
git init
and then from where you pulled your copy initially. Do
git pull /path/to/your/workspace/project/dir

Resources