branch and merge.
I've been using git for a little while now, makes all this very easy [coming from an svn background where branching wouldn't be as easy and would get avoided]
You can branch your code easily:
# first list all your branches so you know what you're on and what else there is
$ git branch
* master # this is the only branch I have right now [and it is the currently checked out branch *]
# new create my new prototype branch
$ git branch prototype
# list my branches again
$ git branch
* master
prototype
# switch to the prototype branch
$ git checkout prototype
Switched to branch 'prototype'
# do whatever changes you want here on the prototype
# switch back to master branch
$ git checkout master
Switched to branch 'master'
You'll eventually need to merge your branches to bring the prototype into the master/production branches. Also simple to do.
These two are some pretty good git resources to get started with:
https://git.wiki.kernel.org/index.php/GitSvnCrashCourse and
http://book.git-scm.com/index.html
My basic workflow when starting a new project is the following:
- Set up a "bare" git repository on my web host [accessible only by ssh]. bare repositories contain only the git information without the actual source files, useful for managing your repo and being able to work across multiple machines easily.
$ mkdir sample_project.git
$ cd sample_project.git
$ git init --bare
Initialized empty Git repository in /home/private/sample_project.git/
- Set up my working local repository in my project folder
# sample_project already exists and contains the project that isn't under version control
$ cd sample_project
$ git init
Initialized empty Git repository in /home/vic/projects/sample_project/.git/
# add all the project files to the repo
$ git add . # using '.' here adds all the files/folders to the repo, you probably want to setup a gitignore file to ignore specific files/extensions/paths.. this can be done later.
# commit your changes
$ git commit -m "initial commit to set up the repo"
[master (root-commit) 1116431] initial commit to set up the repo
0 files changed, 0 insertions(+), 0 deletions(-)
create mode 100644 vic.txt
Worth noting here that commit does a commit on your local git. It didn't send it anywhere. Thats the joy of distributed version control, you have your own history/branches/everything and you can keep commiting locally to keep track of your changes, and then finally push them all and merge with the rest of the project.
Now we have a local and a remote repo, we need to point them at each other. Pretty simple, just set it as a "remote" repository in your local git:
$ git remote add origin ssh://user@mywebhost/home/private/sample_project.git/
$ git push
Now we're connected... git commit/git push will commit our local changes and push it to the server. git fetch/git merge [or git pull] will check for changes on the server and pull them locally.
arithma wrote(as in, how do I define the boundaries of the time spans of the tasks that I commenced, as in, when I get back to the project after a year, how will I know how I did prototype, and where the prototype effects boundaries stop).
git also has tags which might be useful here.