-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathusefull-commands-git
More file actions
171 lines (125 loc) · 3.47 KB
/
usefull-commands-git
File metadata and controls
171 lines (125 loc) · 3.47 KB
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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
#1
#############################
# create repo #
#############################
git remote set-url origin git@github.com:ivanria/dotfiles.git
#prepare rep for ssh authentication
git init
#create repo
touch filename test.c && git add filename *.c
# indexing test.c filename
git clone git://github.com/project.git
#create project folder and clone into folder
git status
# show status of repo
# indexing files, commits
git diff
# compare indexing and not indexing files
git diff --cached
git diff --staged
# copmare staging files and last commit
git commit
# create commit in $EDITOR text editor
#create SHA-1 for commit
git commit -m "first commit"
# do not open editor, commit string pass in quotes
# create SHA-1 for commit
git commit -a
# tracking files. not yet "git add for tracking files"
git rm filename
# release tracking for filename, but file cannot remove from hard drive
# if remove file from hard drive, file stay by tracking as
# not staged for commit
git rm --cashed filename
# release staged for filename and release tracking
git format-patch origin/master --stdout > ../my_extraversion.patch
# create patch between my branch and master branch, wheen HEAD in my brabch
cat .git/HEAD
# to determine what branch i am
#2
####################################
# working with commits and versions#
####################################
git clone git://github.com/someproject.git
cd someproject
git log
# show all commits and SHA-1 sum for commits
git log -p
#show delta beetwen commits
git log -p -2
#delta beetwen -2 last commits
git log --stat
# show statistic for commits
git log --since=2.weeks
# 2 weeks sience commits
git commit -m 'initial commit'
git add forgotten_file
git commit --amend
git push origin master --force
# add fotgotten file to early commit
git reset HEAD file_name
#reset stage fo file_name
git checkout -- file_name
# rollback changes in file_name
git remote -v
# show url for repo
git remote add repo_name git://github.com/project-name.git
# create repo
git fetch git://github.com/project.git
# refresh local repo
git push git://github.com/project.git master
# send local commit to remote server
git show origin
# show remote repo
git remote rename from_name to_name
git remote rm rm_name
# rename rmote repo
# remove remote repo
git fetch --all
git reset --hard origin/master
#reset all local changes
#3
#############################################
# tags #
#############################################
git tag
# view tags
git tag -a v1.4 -m 'version 1.4'
# create tag with comment
git show v1.4
# view tag 1.4 comment and SHA-1
git tag v1.4ligth
# create ligth tag, only tagged commit
git tag -a v1.2 $SHA-1
# tagging erly commit
git push origin --tags
# send all tags to the server
#4
#############################################
# branches #
#############################################
git stash
git checkout -b new_branch
git stash pop
git add *
git commit -m 'new branch'
#hide changes, create branch, pop changes in new branch, commit changes
git branch -d localBranchName
git push origin --delete remoteBranchName
#delete local branch
#delete remote branch
#5
#############################################
# merging #
# ###########################################
git config --global merge.tool vimdiff
#1
git checkout main
git merge experimental-branch
git mergetool
#2
git checkout main
vimdiff test.c <(git show experimental-branch:test.c)
#3
git checkout main
git checkout experimental-branch --patch test.c