Never been to CodeSnippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world (or not, you can keep them private!)

recursevly remove .svn files from an existing repo

If you need to take a project out of scm, you can run this bash script from the top folder - and it will remove all .svn folders recursevly (sp)

Works well for
- changing an svn checkout into and svn export
- switching from svn to git

find . -type d -name '.svn' -exec rm -rf {} \;

git tutorial

// description of your code here

git init
git add .
git commit -a
git log (show previous commits and their unique ids)
git status (show whats changed, and which files are new and untracked)
git checkout [branch] (switch to [branch])
git checkout -b [new_branch_name] (creates branch and switches to it)
git checkout -b [new_branch_name] [commit_id] (ditto, from particular commit)
git pull . [branch] (merges [branch] into current branch)
git reset --hard HEAD^ (undo last merge)


Example of daily use.

Create new rails project
rails rproj
cd rproj
touch .gitignore
touch log/.gitignore
touch tmp/.gitignore
vim .gitignore


Add directories that you don't want git to track into .gitignore...
log/*.log
tmp/**/*
Capfile
doc/api
doc/app


Now start tracking with git...
git init
git add .
git commit -a


Master branch has been created and committed.

Now branch to work on a feature, say hours (automatically switches to it)...
git checkout -b hours


After adding some files, editing a few existing files
git add .
git commit -a


Happy with this branch's work, then merge it into the master branch...
git checkout master
git pull . hours


master branch now contains all changes from hours branch.

Not happy with the changes made in hours after all? Go back to last master commit...
git reset --hard HEAD^


That tells git to return to the previous commit on this current branch, which is master. the carat is what specifies "parent" or previous commit.

Let's go back to hours branch, make changes, then commit it, then merge it back into master.
git checkout hours
[do some changes, no new files]
git commit -a
git checkout master
git pull . hours


Satisfied with changes, lets delete the hours branch...
git branch -D hours


Now let's create a new branch, more_features, based off of the original master commit, containing none of the work from the hours branch of development...
git log
(copy the commit id for the first commit on master)
git checkout -b more_features [commit_id]


Make changes to more_features, commit them, then switch back to master, and merge it in...
git commit -a
git checkout master
git pull . more_features