-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathGIT_DEV
104 lines (72 loc) · 3.79 KB
/
GIT_DEV
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
1. Configuration (l.8)
2. Getting Tom from Git repository (l.20)
3. Useful commands (l.26)
4. Useful links (l.86)
##########################################
1. Configuration
git config --global user.name "<Name that should appear in logs and emails>"
git config --global user.email <email@yourdomain.example.com>
#Optional
git config --global color.diff auto
git config --global color.status auto
git config --global color.branch auto
##########################################
2. Getting Tom from Git repository
git clone ssh://<user>@scm.gforge.inria.fr/git/tom/jtom.git jtom
##########################################
3. Useful (but non exhaustive) commands
git status, git add/rm
git commit : save a modification into the local repository
git push : send local modifications (commits) towards a remote repository
git pull : retrieve the remote version of the repository (/!\ be careful,
depending on the version of Git you are using, on ly the current
branch be retrieved during a pull)
git rebase : merge several commits before pushing in order to see them as a single commit
git branch -a : list branches (remote and local)
git branch -D <branch> : delete a local branch
git branch -m <old_branch> <new_branch> : rename a branch
git checkout <branch> : switch to the branch named <branch> (or retrieve the
content if already in this branch. Erase modifications
which have not been committed). /!\ It is not possible
to switch a branch if there are uncommitted
modifications.
git checkout <branch> -- <file> : retrieve the file named <file> from the branch
named <branch>
git checkout -b <branch> origin/<branch> : create a local branch from remote one
git checkout HEAD <file> : retrieve a deleted file from current branch
git merge <branch> : merge the branch named <branch> into current branch
git push -u origin <branch> : push current branch to the remote repository
git cherry-pick $COMMIT_ID_YOU_WANT : apply a specific commit into the current
branch (useful to import a part of another
branch)
git commit --amend -m "<type here your new message>" : change last commit
message. May be used for
other commits by
modifying a bit the
command.
git reset --hard HEAD~1 : delete last commit (if not pushed, othrewise 'git
revert' has to be used). It is possible to change the
number of commits to reset, or to give the SHA-1 hash
instead of HEAD.
git reset --hard origin/master: retrieve last version of master
What must I do when there is an unsolved conflict:
- solve manually the conflict by editing the problematic file
- execute the following command: git add <file>
- commit it: git commit (/!\ be careful, partial commits are not allowed during,
a conflict resolution)
- push it: git push
##########################################
4. Useful links
[fr] https://wiki.bordeaux.inria.fr/runtime/doku.php?id=git
[en] http://justinhileman.info/article/git-pretty/git-pretty.png (graphical cheat sheet)
[en] http://www.zorched.net/2008/04/14/start-a-new-branch-on-your-remote-git-repository/
[en] http://www.gitready.com/beginner/2009/02/02/push-and-delete-branches.html
[en] http://nvie.com/posts/a-successful-git-branching-model/
[en] http://swcarpentry.github.io/git-novice/01-backup.html
[en] http://betterexplained.com/articles/aha-moments-when-learning-git/
[en] http://git-lectures.github.io/
[en] https://try.github.io/
[en] http://pcottle.github.io/learnGitBranching/
[en] ProGit book (complete reference): http://progit.org/book/
([en] http://git-scm.com/book)
[en] « Version Control with Git » book: http://oreilly.com/catalog/9780596520137