Do some programming
my_vcs commit
Program some more
Realise mistake
my_vcs rollback
Mistake is undone
Sue | James |
---|---|
my_vcs commit |
... |
... | my_vcs checkout |
... | do some programming |
... | my_vcs commit |
my_vcs update |
more programming |
Do some programming | ... |
... | my_vcs commit |
my_vcs commit |
... |
Oh Noes! Error! | ... |
my_vcs commit
|... Oh Noes! Error! |... my_vcs update
|... my_vcs merge
|... my_vcs commit
|... ... |my_vcs commit
... |Error again...
On update, you get a prompt like:
svn update
> Conflict discovered in ’sharedfile.py'.
> Select: (p) postpone, (e) edit, (mc) mine-conflict ...
If you choose (e)
the conflicted file will look something like:
Whatever was in the file before the conflicted bit
<<<<<<< .mine
Sue’s content
=======
Jim’s content
>>>>>>> .r4
Content after the conflicted bit
It is your duty to edit this to fix conflicts, then save.
Update to a particular revision:
svn up -r 3
See the differences between your working area and a revision
svn diff #To most recent version
svn diff -r 3
See what you've changed:
svn status
Get rid of changes to a file:
svn revert myfile.py
Centralised | Distributed |
---|---|
Server has history | Every user has full history |
Your computer has one snapshot | Many local branches |
To access history, need internet | History always available |
You commit to remote server | Users synchronise histories |
cvs, subversion(svn) | git, mercurial (hg), bazaar (bzr) |
Subversion | Git |
---|---|
svn checkout <URL> |
git clone <URL> |
svn commit |
git commit -a; git push |
svn up |
git pull |
svn status |
git status |
svn diff |
git diff |
git remote add sue ssh://sue.ucl.ac.uk/somerepo
# Add a second remote
git remote
# List available remotes
git push sue
# Push to a specific remote
# Default is origin
git branch # Tell me what branches exist
* master # Asterisk tells me which one
experiment # I am currently on
git checkout -b somebranch # Make a new branch
git checkout master # Switch to an existing branch
git push -u origin experiment # Share a recently
# made branch
git push origin experiment #Republish a branch
git branch -r #Discover remote branches
git checkout origin/some_branch #Get a branch
#from a remote
git checkout master # Switch to master branch
git merge experiment # Merge the branch in
git branch -d experiment # Delete branch locally
git push --delete experiment # Delete published branch
production
branch: code used for active workdevelop
branch: for general new codefeature
branches: for specific new ideasrelease
branches: when you share code with othersEasy to read labels for revisions Produce real results only with tagged revisions
git tag -a v1.3
git push --tags
git init --bare
to make a copy for pushing