Basic git for a Local Repo
I'm still not fully sold on git, but sometimes it's nice to set up version control for a single project. It's nice to be able to track what you've done, roll back experiments and otherwise protect your work (and sanity.) This is just an annotated account of this process for a small project I was doing with CakePHP, half to later refresh my memory and half for others doing the same.
> git init # create the in-place repo
> git add app # add files
> echo “.gitignore” >.gitignore # ignore some files
> echo “cake” » .gitignore
> echo “.htaccess” » .gitignore
> git branch working # create scratchpad
> git checkout working # start working on it.
Switched to branch “working”
- edit some files
> git status
- On branch working
- Changed but not updated:
- (use “git add
…” to update what will be committed)
# - modified: app/controllers/events_controller.php
#
no changes added to commit (use “git add” and/or “git commit -a”)
> git add events_controller.php
- On branch working
- Changes to be committed:
- (use “git reset HEAD
…” to unstage)
# - modified: app/controllers/events_controller.php
#
- rinse and repeat until you're done with a chunk of work
> git commit -m”Bug fixes” # commit this set of changes to the working branch
> git diff ../maste # see what you changed
> git checkout master # head back to original
> git merge working # merge your changes in
Back to Blog Home »