git常用命令笔记

 1 git
 2 
 3 git config –global user.name
 4 
 5 git config –global user.email
 6 
 7 mkdir repository.name
 8 
 9 cd repo.name
10 
11 pwd // show the current path
12 
13 git init // init the folder to git.repo
14 
15 git add file.name
16 
17 git commit -m “commit message”
18 
19 git status
20 
21 git diff file.name
22 
23 git log // check the commit history
24 
25 git log –pretty=online
26 
27 (HEAD,HEAD^,HEAD^^,HEAD~100) the latest
28 
29 git reset –hard commit.idgit reflog // check all command history
30 
31 workplace | stage | master
32 
33 git diff HEAD –file.name
34 
35 git checkout — file.name // repeal all files in workplace, recover all workplace files to the lastert status
36 
37 git reset HEAD file.name // unstagerm file.name
38 
39 git rm file.name
40 
41 git commit -m “remove message file.name”
42 
43 (another situation of wrong delete)git checkout — rm.filename
44 
45 ssh-keygen -t rsa -C “41695562@qq.com”
46 
47 git remote add origin git@github.com:niceforbear/repo_name.git // origin is default name of remote library
48 
49 git push -u origin master // first use
50 
51 git push origin master // second and later use
52 
53 git clone git@github.com:niceforbear/clone_name.git
54 
55 cd clone_name
56 
57 ls
58 
59 git checkout -b branch_name // switched to a new branch
60 
61 branch_name
62 
63 git branch branch_name
64 
65 git check branch_name
66 
67 git branch // check
68 
69 git add/commit // all on the * branch
70 
71 git checkout master // switched to branch ‘master’
72 
73 git merge branch_name // merge branch_name to current branch
74 
75 git branch -d branch_name // deleted branch branch_name
76 
77 git log –graph –pretty=online –abbrev-commit // check merge branch graph
78 
79 git merge –no-ff -m “merge message with no-ff” branch_name // there is a branch in the history log

 

posted @ 2015-05-22 01:14  niceforbear  阅读(176)  评论(0编辑  收藏  举报