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.
Related
How do I clean my build artifacts with Tup?
My project generates a lot of artifacts that I would like to have cleaned up. Tup doesn't seem to have a way to do it, and git reset --hard HEAD, even after a git add -Af, doesn't work.
Just for completeness, you can keep things clean with variants.
touch default.config # An empty config file is ok
tup variant default
tup
Build files will go in the directory ./build-default.
If you do the above in an active tup project, tup will remove all the in-situ build files and move them to the build directory for you.
There is nothing special about the tup variant command. It just provides a little automation. The following would acheive the same:
touch default.config
mkdir build-default
ln -s default.config build-default/tup.config
tup
Tup does not have a clean function like Makefiles can define.
If you're using a Git repository, you can git-clean your repository.
$ git add -A
$ git reset --hard HEAD
$ git clean -dffx
If you're working on some changes and need to clean away all of the stuff without killing your changes, use:
$ git clean -Xf
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
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/
I have made a naive mistake while setting up my project. We are 3 developers working on one remote repository. While setting up git we never thought that Xcode would produce non-development files and push them to our remote repo. Now once I learnt after crash and burn I made a .gitignore file.
.gitignore looks like this, please do let me know if I should edit this too. (File credit goes too : This question's answer given by Abizem)
# Mac OS X
*.DS_Store
# Xcode
*.pbxuser
*.mode1v3
*.mode2v3
*.perspectivev3
*.xcuserstate
project.xcworkspace/
xcuserdata/
But now question is there any possibilities that I can untrack all of those listed files from our source control?
or
Can I list all tracked files with their path and later I know a painful way to remove one by one with,
git rm --cached 'file path'
Something I've done a few times in these situations, is move all of the files in the repository somewhere else on the filesystem (except .gitignore), then run:
git add --all
git commit -m "Remove all files"
Then add your files back in and run the following:
git add --all
git commit -m "Re-add files"
This second add & commit will adhere to your gitignore file.
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.