DVCS (such as Git, Mercurial, Bazaar or Darcs)
Git was written by Linus Torvalds on the first version,He described the tool as “the stupid content tracker”,So don’t be afraid of Git.
It is a good idea to introduce yourself to Git with your name and
public email address before doing any operation. The easiest
way to do so is:
$ git config --global user.name "Your Name Comes Here" $ git config --global user.email email@example.com
Initialized empty Git repository in .git/
git add .
Git tracks content not files
Many revision control systems provide an `add` command that tells the
system to start tracking changes to a new file. Git’s `add` command
does something simpler and more powerful: ‘git add’ is used both for new
and newly modified files, and in both cases it takes a snapshot of the
given files and stages that content in the index, ready for inclusion in
the next commit.
This snapshot is now stored in a temporary staging area which Git calls
the “index”. You can permanently store the contents of the index in the
repository with ‘git commit’:
A note on commit messages: Though not required, it’s a good idea to
begin the commit message with a single short (less than 50 character)
line summarizing the change, followed by a blank line and then a more
thorough description. The text up to the first blank line in a commit
message is treated as the commit title, and that title is used
throughout Git. For example, linkgit:git-format-patch turns a
commit into email, and it uses the title on the Subject line and the
rest of the commit in the body.
git commit -a
which will automatically notice any modified (but not new) files, add
them to the index, and commit, all in one step.
git add file1 file2 file3
You are now ready to commit. You can see what is about to be committed
using ‘git diff’ with the –cached option:
git diff --cached
$ git status
If you also want to see complete diffs at each step, use
git log -p
git checkout 'your_branch'
git merge 'some one branch'
If the changes don’t conflict, you’re done. If there are conflicts,
markers will be left in the problematic files showing the conflict;
will show a nice graphical representation of the resulting history.
At this point you could delete the experimental branch with
git branch -d 'your_branch'
git clone /home/alice/project myrepo
The “pull” command thus performs two operations: it fetches changes
from a remote branch, then merges them into the current branch
local changes committed before
initiating this “pull”.
git pull /home/bob/myrepo master
git fetch /home/bob/myrepo master
git log -p HEAD..FETCH_HEAD
git difftool --tool-help
git rm git rm --cached
git commit --amend
git checkout -- <file>
git remote add pb https://github.com/paulboone/ticgit
git push [remote-name] [branch-name]
git remote show [remote-name]
git remote rename
git remote rm paul
git checkout -b version2 v2.0.0
permanently delete remote ref
git push --delete rep ref git push rep :ref eg..git push --delete origin dev is equivalent to git push origin :dev