Rubymine can't load file projects after running git clean - ruby-on-rails

I have added some files to .gitignore, then run the command git clean -options to clean some untracked files. (Sorry, I don't remember what options I used). Then, Rubymine can't load all files in my projects. I open the project source tree, and all I can see are the following files .gitignore, Gemfile, Gemfile.lock, Readme.md, and some other unimportant files. I think the problem occurs because of the git command I use above. I am wondering if anybody has faced this problem before. Any suggestions are appreciated.

Check this, hope this may save you
git reflog it is explained here
http://gitready.com/intermediate/2009/02/09/reflog-your-safety-net.html
Also remember you can always go back to your previous stable commit git checkout [revision] or undoing your changes.
https://www.atlassian.com/git/tutorials/undoing-changes

Related

Rails app turned into HTML on GitHub as I forgot to gitignore

I added SimpleCov and forgot to .gitignore 'coverage' and now my Rails app has accidentally turned into a HTML app on GitHub. This is where my app lives: https://github.com/GeekG1rl/lemon
I tried to add 'coverage' to my .gitignore afterwards and push again but it hasn't updated in my repo (probably because the file is still there).
My assumption is that the directory has already been built but if I delete it, then push again (with 'coverage' in .gitignore), then it will build locally only when being run? If that breaks more things though, I won’t know how to undo that so I'm asking for help before completely breaking it.
I've been coding for three months so please don't be mean if this turns out to be a stupid question ;)
git rm -rf coverage
git commit -m "Remove coverage folder"
git push origin master
.gitignore only covers newly added files and directories, you must manually remove any existing files or directories when you add them to .gitignore.

Git merge conflict with workspace.xml

I'm trying to push my Rails project to Heroku, but Git isn't allowing me to do anything at the moment. Here's what I've done so far:
git push heroku failed because the heroku branch was "ahead" of my local branch, which should not have been possible.
I pulled and there was a conflict with .idea/workspace.xml. I wasn't able to find out what that file is, but it's huge and Git wrote all kinds of garble to it. Too much to manually "resolve" conflicts.
I saw some stackoverflow posts talking about git-ignoring that file (maybe it's some IDE file for RubyMine or something?), so I tried to move the file away to avoid the conflict
I ran git add -A (also tried git add . and git add)
git commit --amend fails because "You are in the middle of a merge"
git merge --abort fails because "Untracked working tree file '.idea/workspace.xml' would be overwritten by merge (despite the fact that the file has been moved)
git reset --merge fails for the same reason.
How can I make Git work again?
.idea/workspace.xml
This file is your idea workspace files. They are generated by IntelliJ tools.
I saw some stackoverflow posts talking about git-ignoring that file (maybe it's some IDE file for RubyMine or something?), so I tried to move the file away to avoid the conflict
Simply add the folder to your .gitignore but since its already committed you will have to remove it from the repository:
# Quit the merge
git merge --abort
# remove the whole folder from the repo
git rm -rf --cached .idea/
# add it to the .gitignore: idea/
# add and commit your changes
git add .- A
git commit -m " Removed idea folder"
git push origin <branch>
If you still unable to do it?
First reset the code to the previous state and then do the above code again.
The reset will take you to your last commit before the pull
git commit -am "message" worked (as opposed to amending a commit)
I have resolved a similar problem by simply deleting the workspace.xml file. By building and running the program again idea will autogenerate a compatible file.

Starting over with Git

I decided to learn how to use Version Control over Christmas break, so I downloaded Git, opened a GitHub account and started reading the online tutorial linked to from the GitHub website. When I got to this part http://progit.org/book/ch2-2.html I got stuck because I wasn't sure how to add files. For instance, I tried
git add C:/Finish.txt
And it said
Fatal: 'C:/Finish.txt' is outside repository
I was confused until I remember that a long time ago I had tried teaching myself Ruby on Rails and played around with Git back then. It never really went anywhere, but there's all this residual stuff floating around my system and I don't know how to change it. For instance, my Untracked files (which should be empty) are rails_projects/ and sample/.
How can I just erase all the old stuff and start over?
You should make a folder for your repository, move Finish.txt to that repository, then do git add.
For example:
# here you create C:\myrepo
cd C:\myrepo
git init .
# here you edit C:\myrepo\Finish.txt
git add Finish.txt
git commit -m "Added Finish.txt"
Start a new repository, e.g.
c:
md c:\newrepo
cd c:\newrepo
git init .
copy \Finish.txt .
git add Finish.txt
git commit -m "started over"
I strongly recommend against adding anything to C:\, let alone putting a git repo there. Unless of course you want to accidentally add all of your system disk to git :)
I can also heartily recommend using TortoiseGit which has some excellent explorer integration.
Delete any .git folder that you find in your drive.
To create a repo go to a folder that you want the repo in ( and not just randomly), do:
git init
Then proceed... Add only files that you put within this repo and not randomly from some location.
It would be very unusual to have the root directory of your hard drive be a git repository. That's probably why it's giving you the error.
git repositories are typically in a subdirectory and that subdirectory is typically a project.
To initialize a subdirectory as a git repository, you'd do:
git init (directory)
Then you'd add your files and commit.

Git not recognizing rails plugin

I installed the table_builder plugin from https://github.com/p8/table_builder, followed the directions at the bottom titled For a pre rails 3.0 table_builder: which works great.
The problem is since I checked out a branch of it, when I try to commit this to MY GIT repo, it doesnt think there are files even there.. git status diplays nothing, git add wont add the files..
Any suggestions as to how I can get this committed?
Maybe you cloned the plugin directly into your own repository and you now have the plugin repository within your repository?
A git repository will by default ignore any other repositories and their working directories that are located within it.
If so, you have (at least) two options:
Clone the plugin elsewhere, and then
copy the necessary files into your
repository
Clone the plugin into your repository
and then delete the plugin's .git
folder
There are other ways to manage this with git-submodule but I'm not an expert on that so I defer to someone with more knowledge.
Check the .gitignore file in your project root folder. If git status doesn't see the files and git add won't add them, it's most likely because they're being specifically ignored.

should script/plugin create a .git folder?

I noticed that if I do something like:
script/plugin install git://github.com/plug-xyz.git
It says it is creating a .git folder:
Initialized empty Git repository in /Users/g/Documents/app/vendor/plugins/xyz/.git/
But after the plugin is installed, it seems that the .git folder is gone.
I ask because when I try to update the plugin, nothing happens. It says it is updating, but when I check the files, they have not been updated to the latest version. I then removed the plugin, and re-installed it, and it was able to grab the most recent version.
Is it not possible to perform script/plugin update on git plugins?
You can see the changeset here: http://dev.rubyonrails.org/changeset/9049
It does remove the .git folder, presumably to save space by not storing history. This is traditional for a source control "install" instead of "checkout" or "clone" command, although it doesn't use a hypothetical "git install" command to do this.
script/plugin update looks for the .svn directory in each plugin so it can run svn update. That obviously won't work for git checkouts whether or not their .git folder has been removed. You should edit that script and send them a patch to enable the git version of update. It would probably be a pretty simple change.
.git folder is removed so that it doesn't get checked into your own SCM. For example, not everyone's using Git as their SCM (me for one) and wouldn't want to check in .git repos into my own for obvious reasons.
According to the help spat out by script/plugin, -x option would add SVN external. I found these two articles addressing this specific issue, but haven't tried solutions since I don't use .git

Resources