Overview and introduction to Git - an open source version control system designed to handle very large projects with speed and efficiency, but just as well suited for small personal repositories.
A note about local cloning.
git knows where you cloned from, and arranges for the the changes to be pushed back there.
but in /orig/repo the changes won't be there yet. You need to :
See git for cvs users.
Ensure everyone has group read/write permissions on that directory. Then they can clone the repository with:
View
Change/set - current repository only
Change/set - in ALL your (local) repositories. This updates ~/.gitconfig
Alternatively edit ~/.gitconfig directly
create cake.txt and add some text to it.
to commit it:
or
or
or
Edit cake.txt but do not commit it.
Show the differences
Show the differences with color
Show a summary of the changes
Add the file to the index, and try diff
see all the commits:
see all the commits, with the diff's:
note that these show you what happened on the current branch. Switch branches, and you'll likely get a different log (unless you've just branched).
Create a branch
Show branches that exist. * indicates the current branch
Change to branch "oven_temp"
Change back to "master", aka, trunk
Or, to create a branch and change to it in one step:
Make a change on the branch
Change back to master, and merge in the change
Delete the oven_temp branch
Think of it as:
Or put another way:
If conflicts occur, and sooner or later they will,
See also "git-mergetool"
You want:
COMMIT_ID should be the one BEFORE you want to fiddle with.
To learn about splitting a single commit up into multiple commits:
A change applies to the branch you are on when you COMMIT. Not when you edit or add the file.
although you've switched branches (from cream to master), the file still exists. Until you've committed it, it's not really part of git yet.
cream.txt is no longer there. You where on master when it was committed, you're now on the cream branch.
cream.txt exists again. If you want to get the file back into the cream branch, rebase is your friend:
it is only safe to amend the commit messages that have not been seen by anyone else (aka, you've not pushed, nobody else has pulled from you).
This will throw away ALL your uncommitted changes.
Any (and all) changes will be un-done. Files you deleted will be recovered (provided they have been added to the git repository). If you had added any files to the index (git add), they will be undone.
You'll have a fresh, clean, current copy of the head / master / trunk.
If you've created a file, but never committed it, it will remain un-touched.
Remove the file, and checkout a fresh copy
If you had previously added the file to the index, even the above will still leave git thinking cake.txt has been modified:
To "unstage" a file, aka remove it from the index:
You'll still have your file, it'll still contain your original changes, but it won't get committed until you re-add it to the index (or commit -a, or commit <path>)
You've committed a bunch of things, but you want to "remove" some of the commits, merge other, adjust the commit messages.
This only works if nobody else has seen your changes. You've not pushed, nobody has pulled.
First, make sure everything is commited.
Next, use "git log [-p]" to find the commit id where you would have branched, and the commit id of most recent point in history.
If you hit conflicts, fix them, then:
~/.gitconfig
The bits on the left of the = in the [alias] section you can change to anything you prefer.
[user] # Edit by hand, or via "git config --global user.name" etc. name = Nemo email = nemo@sysmonblog.co.uk [color] # Ensure we get color diff = auto branch = auto status = auto [alias] # shortcuts b = branch c = checkout co = commit d = diff -b dc = diff -b --cached ds = diff -b --stat s = status # summary of what you're going to push ps = log --pretty=oneline origin..master # like "git log", but include the diffs w = whatchanged -p # changes since we last did a push wo = whatchanged -p origin..
The follow we have found useful/interesting:
We'd welcome tips, suggestions, corrections, feedback or comments via email or as comments on our blog.
Copyright 2008 blog@sysmonblog.co.uk