I have tryed to run this code in my console:
script/plugin install git://github.com/apotonick/cells.git
...but i only get an empty folder named "cells" in my "vendor/plugins" dir.
What's wrong?
Check you Git version.
This may be related with you gitconfig file, as described in this thread
The reason is that it appears rails-2.3.5/lib/commands/plugin.rb is trying use git pull to grab the plugin code (see the install_using_git method), which doesn't work right.
Example:
script/plugin install git://github.com/fesplugas/typus.git
mkdir vendor/plugins/typus
cd vendor/plugins/typus
git init
git pull --depth 1 git://github.com/fesplugas/typus.git
That last line exits 1, but that error is being masked by the install_using_git method, and the directory is just rm -rf'ed.
I tracked this down to a conflict with ~/.gitconfig. If I remove these lines it works:
[branch "master"]
remote = origin
merge = refs/heads/master
It appears a naked git pull has problems with these settings.
Actually, the problem would be here because of a global git config file (in your homedir: '~/.gitconfig'), defining a master which may be incompatible with the master expected by the git pull within that specific Git repo.
Related
I wanted to add screen shot of that, but i didn't have that much reputation as I am new to this. I am getting fatal message i.e not a git repository, when I am typing "git add ." in git command prompt. I am currently new to ruby on rails.What should I do?
It sounds to me that when you are executing git add . your current directory is not part of the working tree of a git repository.
Make sure that there is a .git folder (containing the Git repository) in you current directory or a parent directory of the current directory. If there is not, you need to properly initialize a git repository by git clone (if you are starting from some other git repository) or git init (if you are starting a new repository).
So I need to upgrade an rails 2.3.14 app to rails 3. We use git, so decided to create another branch 'rails3' (git checkout -b rails3). The easiest solution I found to the problem of the upgrade was removing all stuff and generating a new project and copy/pasting controllers , views, etc.. from master. But now git status tells me those files were deleted and regenerated, not modified, although most of them are in the same place they were before. So changes remain obscure, other programmers wont see the subtle changes to files.
What have I've done:
/path/to/rails_project/ (master) $ git checkout -b rails3
/path/to/rails_project/ (rails3) $ rm -rf ./* # not git rm
/path/to/ $ rails new rails_project
/path/to/rails_project/ (rails3) $ cp old/project/stuff/from/another/dir
How can I 'tell' git that these files were modified, not deleted and regenerated? I have the upgraded app in a totally different directory so its fine to implode cosmos and do all from start.
Looks like git is right if what you said below is correct
"The easiest solution I found to the problem of the upgrade was removing all stuff and generating a new project and copy/pasting controllers , views, etc.. from master."
If the files are as you want them to be, why not just:
git add
git commit
Git doesn't automatically delete anything. You must have been using an IDE or editor that was calling git rm ... and then git add ... and you just didn't see it.
To avoid this, use git at command line or with a tool that is more obvious. And instead of git rm and git add for something that is the same file, use git mv. Sometimes git figures out moves on its own when you rm and add, but with mv it doesn't have to guess.
I just made tried to do git checkout master and I got this error:
macoss-MacBook-Pro-10:Marketing owner12$ git checkout master
error: The following untracked working tree files would be overwritten by checkout:
Marketing.xcodeproj/project.xcworkspace/xcuserdata/owner12.xcuserdatad/UserInterfaceState.xcuserstate
Please move or remove them before you can switch branches.
Aborting
but I am not sure how to handle this situation. I don't mind having this file overwritten by what is in the repo. What is the correct way for me to proceed here?
Thanks!
You have files that are not being tracked. Either
rm untracked.file1 untracked.file2
or
git add . && git commit -m "adding new previously untracked files that serve a purpose"
if you're having permission issues:
git add --ignore-errors .
Either delete the file if you don't care about it or stash it if you think you will need it in the future. Or simply rename.
Commit the files you want to keep and then do a git clean to remove the extra files you don't want to keep. This article on the git ready website describes it very well.
If you just want to get rid of one or two files in your working directory then you can do a dry run first and see which files would be cleaned up using:
git clean -n
And then when you are sure do this:
git clean -f
git clean has a -d switch if you want to clean up directories as well. And you can use that together with the other switches, so this is what I would normally use (and then after the dry run change -n to -f):
git clean -n -d
Then after your git clean, use:
git status
to make sure that you have no untracked files or uncommitted changes. And lastly switch to master with:
git checkout master
In a Rails app I realised I had committed a sensitive file config/credentials.yml to the git repo.
In an effort to tidy things up I followed the advice on GitHub and ran
git filter-branch --index-filter 'git rm --cached --ignore-unmatch config/credentials.yml' --prune-empty --tag-name-filter cat -- --all
and then added to gitignore
echo "config/credentials.yml" >> .gitignore
When I try to commit these changes
git add .gitignore
git commit -m "ignored credentials.yml"
I'm getting a message
error: pathspec 'adds credentials.yml to gitignore' did not match any file(s) known to git.
How can I fix this error? Or, how can I undo my changes and safely revert to the git history on my remote?
I think you might've forgotten the step
$ git add .gitignore
before trying to commit, or then you mistyped, when you shoud've given
$ git commit -m "Add credentials.yml to .gitignore"
Process advised is highly dangerous [for the repo contents], so one must be really careful to follow all the steps in detail.
Just give a file path while adding file to git add command, it works for me
$ git add mainFolder/.../file.extension
Note: mainFolder would be the folder inside your repo
So, I'm a newbie at git, but I'm using it because I have my rails app deployed through heroku. My app generates a bookmarklet (which is just a js file) for each user upon sign-up. Unfortunately, when I deploy, all of the bookmarklets for the users on the live site get overwritten with the bookmarklets for the users on my dev environment. I've read some other questions about this kind of thing, and I know I'll have to add the bookmarklet folder to the .gitignore file, and something about rm --cache (but I'm not sure exactly what I'll have to do). I tried doing these things, but I'm wondering if the problem is that git is ignoring all of the files that are there now, but isn't ignoring the ones that are generated after doing the whole gitignore process. Either that or I'm just doing it wrong (this is very, very likely).
Any help is welcome. And sorry that this covers the same ground as a lot of other similar questions. I did as much research as I could.
Thanks.
Here some simple steps:
Create a file .gitignore in the root of your repository, with the following simple content:
/path/to_your/folder
Add the file to your repository:
git add .gitignore
Remove the folder from your repository (this won’t physically delete the folder):
git rm --cached /path/to_your/folder
Commit
git commit
After that, the folder should be removed from your repository and subsequent changes in it will be ignored by git.
Sounds like Heroku is cleaning out every file not checked in to your Git repository when you deploy. Modify your app to save the bookmarklets to a directory outside of your Git repository.
#poke's answer is mostly correct, but the leading slash in the path name is problematic so I'm posting revised instructions.
The following steps assume the subdirectory inside your git repository is named foo.
Make sure you're at the top level of your Git working directory:
cd "$(git rev-parse --show-toplevel)"
Add foo to your top-level .gitignore file:
echo /foo/ >>.gitignore
The leading slash says to ignore foo in the top level but not */foo or */*/foo, etc. The trailing slash says to ignore foo if it is a directory, but not if it is a file or symbolic link.
Stage the newly modified .gitignore:
git add .gitignore
Commit:
git commit -m "Add foo to .gitignore"
Stop tracking the contents of the foo directory in the Git repository:
git rm -r --cached foo
The --cached option tells Git to not delete the foo folder from your working directory.
Commit:
git commit -m "Remove the foo directory"
Add the following to your .gitignore:
path/to/ignore/**/*
If there are already tracked files on that path, they won't be ignored.
You'll have to run
git rm -r --cached path/to/ignore/