Git
Refs
master
branchName
commitHash
HEAD
Relative Refs
^
moving up one commit e.g. git checkout HEAD^
^N
moving up from merge commit to second parent e.g. git checkout HEAD^2
~N
moving up N times e.g. git checkout HEAD~4
Moving branches around
move master to 3 commit behind HEAD git branch -f master HEAD~3
Reversing changes
Reset
git reset HEAD~1
moves branch commit behind
Revert
git revert HEAD
commits inverted changes
Modify last
git commit --amend
Moving commits around
git cherry-pick <c1> <c2> <...>
copy commits below HEAD
Interactive rebase, reorder, drop, squash
git rebase -i HEAD~4
Tags
git tag v1 C1
Git describe
git describe <ref>
git checkout
git bisect
init
clone
add
commit
branch
git branch -r
merge
diff
log
status
checkout
push
fetch
pull
- Commit ID
- content
- author
- date
- log message
- previous commit
- content
git svn dcommit
Commit each diff from a specified head directly to the SVN repository, and then rebase or reset (depending on whether or not there is a diff between SVN and head). This will create a revision in SVN for each commit in git. It is recommended that you run git-svn fetch and rebase (not pull or merge) your commits against the latest changes in the SVN repository. An optional command-line argument may be specified as an alternative to HEAD. This is advantageous over set-tree (below) because it produces cleaner, more linear history
GIT
http://stackoverflow.com/search?q=visual-studio+git
http://code.google.com/p/msysgit/
http://code.google.com/p/tortoisegit/
git svn
git svn init http://path/to/svn/project/trunk projectname
cd projectname
git svn fetch -rREVISION (most likely this will be git svn fetch -rHEAD
git svn rebase
http://git-scm.com/book/en/Git-and-Other-Systems-Git-and-Subversion
http://git-scm.com/docs/git-svn
git svn clone file:///tmp/test-svn -T trunk -b branches -t tags
or
git svn clone file:///tmp/test-svn -s
add all folders as submodule
find . -type d -maxdepth 1 -exec git submodule add {} \;
update all submodules
git submodule foreach git svn fetch
show all repository status
git submodule foreach git svn info
show global config
git config --global -l
git rm –cached
clone
push
pull
fetch
branch
checkout
init
format-patch
send-email
log
show
describe
diff
blame
bisect
rebase
cherry-pick
reset
stash
apply
add
rm
mv
am
revert
status
commit
remote
ls-remote
Cancel commit and back to staging area
git reset --soft HEAD^
edit commit message
git commit --amend -m "New commit message"
hard reset remote
$ git push --force origin
merge two commits into one
Get back to where you started with
$ git rebase --abort
Say your history is
$ git log --pretty=oneline
a931ac7c808e2471b22b5bd20f0cad046b1c5d0d c
b76d157d507e819d7511132bdb5a80dd421d854f b
df239176e1a2ffac927d8b496ea00d5488481db5 a
That is, a was the first commit, then b, and finally c.
Running git rebase --interactive HEAD~2
gives you an editor with
pick b76d157 b
pick a931ac7 c
# Rebase df23917..a931ac7 onto df23917
#
# Commands:
# p, pick = use commit
# r, reword = use commit, but edit the commit message
# e, edit = use commit, but stop for amending
# s, squash = use commit, but meld into previous commit
# f, fixup = like "squash", but discard this commit's log message
#
# If you remove a line here THAT COMMIT WILL BE LOST.
# However, if you remove everything, the rebase will be aborted.
#
Changing b’s pick
to squash
will result in the error you saw, but if instead you squash c into b by changing the text to
pick b76d157 b
s a931ac7 c
and save-quitting your editor, you'll get another editor whose contents are
# This is a combination of 2 commits.
# The first commit's message is:
b
# This is the 2nd commit message:
c
When you save and quit, the contents of the edited file become commit message of the new combined commit:
$ git log --pretty=oneline
18fd73d3ce748f2a58d1b566c03dd9dafe0b6b4f b and c
df239176e1a2ffac927d8b496ea00d5488481db5 a
git log –pretty=oneline
git log –summary
git remote add origin git@github.com:diimdeep/try_git.git
git push -u origin master
git pull origin master
git diff HEAD
git diff –staged
git reset path/to/file
git checkout –
git branch clean_up
git checkout -b new_branch
git stash
git stash apply
http://githowto.com/ru/
https://www.youtube.com/watch?v=qyz3jkOBbQY
http://zachholman.com/posts/how-github-works/
http://git-scm.com/docs
http://git-scm.com/book
http://githowto.com/ru/
http://diseaz.github.com/gitmagic/
http://ftp.newartisans.com/pub/git.from.bottom.up.pdf
http://vimeo.com/14629850
http://git-scm.com/book
http://rogerdudler.github.com/git-guide/
http://try.github.com/levels/1/challenges/1
http://book.git-scm.com/
http://peepcode.com/products/git-internals-pdf
Все команды Git на самом деле просто команды манипуляции графом
Git имеет больше смысла когда ты понимаешь X
Пример 1: (Kent Beck)[http://en.wikipedia.org/wiki/Kent_Beck]
«Наконец то понял что комманды git это странно названные команды манипулции графом: создание/удаление узлов, перемещение указателей»
Git config
[user]
name = Dmitry Wolf
email = frensys@gmail.com
[color]
diff = auto
status = auto
branch = auto
[alias]
ci = commit -a
cl = clean -dfx
cc = cherry-pick
ff = merge --ff-only
fx = commit -a --amend -C HEAD
ix = diff --cached
st = status -sb
hist = log --all --graph --pretty='[%C(cyan)%h%Creset]%C(bold cyan)%d%Creset %s'
git diff
git hist %%
git branch -d %%
git merge %%
git rebase -i %%
git rebase –abort
git log ORIG_HEAD
git gc -prun
git gc -prune
git tag version-1.0
git stash
git stash list
git stash apply
git stash clear
git reset HEAD^
git reflog
git remote add %url%
git fetch
git pull
git log –pretty=oneline –abbrev-commit –branches=*
git log –pretty=oneline –abbrev-commit –branches=* –graph
git log –pretty=oneline –abbrev-commit –branches=* –graph –decorate
git commit –amend
Local branch commands: commit, merge, rebase, reset
Remote branch commands: fetch, push
Tag: tag
git merge
SCOUT PATTERN
Check status - should be clear
git status# On branch master nothing to commit (working directory clean)
Create new branch for testing
git checkout -b %test_merge%Merge with existing branch
git merge %existing_branch%If bad happens - full back
git reset –hardif OK
git checkout master
git merge %test_merge%if NOT
git checkout master
git branch -D %test_merge%
SAVEPOINT PATTERN
Check status - should be clear
git status# On branch master nothing to commit (working directory clean)
Create new branch as savepoint
git checkout -b %savepoint%Merge with existing branch
git merge %existing_branch%if OK - Delete the savepoint. s
git branch -d savepointif NOT - reset your branch to the savepoint.
git reset –hard savepoint
####### git reset –hard %accept%:
- Branch names
- Tags
- Relative references like HEAD^, HEAD^^, or HEAD~3
- partial SHA-1 hashes like 8d434382
scp -r reponame deploy@hostname.com:reponame
vi
:wq - save & exit
i - editor mode
esc - out
:w -save
:q - quit
:q! - exit without saving
Mac OS X
Windows
http://gitscc.codeplex.com/
http://code.google.com/p/gitextensions/
http://code.google.com/p/msysgit/
http://code.google.com/p/tortoisegit/