Skip to content

Commit e295734

Browse files
committed
翻译,修改,删除:git指令(持续工作)
1 parent 9def7b6 commit e295734

File tree

1 file changed

+34
-95
lines changed

1 file changed

+34
-95
lines changed

README.md

Lines changed: 34 additions & 95 deletions
Original file line numberDiff line numberDiff line change
@@ -137,13 +137,9 @@
137137
2. 暂存区:输入命令:`git add 改动的文件名`,此次改动就放到了‘暂存区’
138138
3. 本地仓库:输入命令:`git commit 此次修改的描述`,此次改动就放到了’本地仓库’,每个commit,我叫它为一个‘版本’
139139
4. 远程仓库:输入命令:`git push 远程仓库`,此次改动就放到了‘远程仓库’(github等)
140+
5. commit-id:
140141

141-
## Everyday Git in twenty commands or so
142-
```sh
143-
git help everyday
144-
```
145-
146-
## Show helpful guides that come with Git
142+
## 展示帮助信息
147143
```sh
148144
git help -g
149145
```
@@ -178,11 +174,6 @@ git diff --cached
178174
git diff HEAD
179175
```
180176

181-
## List all branches that are already merged into master
182-
```sh
183-
git branch --merged master
184-
```
185-
186177
## 快速切换分支
187178
```sh
188179
git checkout -
@@ -229,39 +220,40 @@ git tag -d <tag-name>
229220
git push origin :refs/tags/<tag-name>
230221
```
231222

232-
## Undo local changes with the last content in head
223+
## 放弃工作区的修改
233224
```sh
234-
git checkout -- <file_name>
225+
git checkout <file_name>
235226
```
236227

237-
## Revert: Undo a commit by creating a new commit
228+
放弃所有修改:
238229
```sh
239-
git revert <commit-ish>
230+
git checkout .
240231
```
241232

242-
## Reset: Discard commits, advised for private branch
233+
## 回到某一个commit的状态,并重新增添一个commit
243234
```sh
244-
git reset <commit-ish>
235+
git revert <commit-id>
245236
```
246237

247-
## Reword the previous commit message
238+
## 回到某个commit的状态,并删除后面的commit
239+
和revert的区别:reset命令会抹去某个commit id之后的所有commit
248240
```sh
249-
git commit -v --amend
241+
git reset <commit-id>
250242
```
251243

252-
## See commit history for just the current branch
244+
## 修改上一个commit的描述
253245
```sh
254-
git cherry -v master
246+
git commit --amend
255247
```
256248

257-
## Amend author.
249+
## 查看commit历史
258250
```sh
259-
git commit --amend --author='Author Name <email@address.com>'
251+
git log
260252
```
261253

262-
## Reset author, after author has been changed in the global config.
254+
## 修改作者名
263255
```sh
264-
git commit --amend --reset-author --no-edit
256+
git commit --amend --author='Author Name <email@address.com>'
265257
```
266258

267259
## 修改远程仓库的url
@@ -286,113 +278,65 @@ git branch -a
286278
git branch -r
287279
```
288280

289-
## Stage parts of a changed file, instead of the entire file
290-
```sh
291-
git add -p
292-
```
293-
294-
## Get git bash completion
295-
```sh
296-
curl http://git.io/vfhol > ~/.git-completion.bash && echo '[ -f ~/.git-completion.bash ] && . ~/.git-completion.bash' >> ~/.bashrc
297-
```
298-
299281
## 查看两个星期内的改动
300282
```sh
301283
git whatchanged --since='2 weeks ago'
302284
```
303285

304-
## See all commits made since forking from master
286+
## 把A分支的某一个commit,放到B分支上
287+
这个过程需要`cherry-pick`命令,[参考](http://sg552.iteye.com/blog/1300713#bc2367928)
305288
```sh
306-
git log --no-merges --stat --reverse master..
289+
git checkout <branch-name> && git cherry-pick <commit-id>
307290
```
308291

309-
## Pick commits across branches using cherry-pick
310-
```sh
311-
git checkout <branch-name> && git cherry-pick <commit-ish>
312-
```
292+
## 给git命令起别名
293+
简化命令
313294

314-
## Find out branches containing commit-hash
315295
```sh
316-
git branch -a --contains <commit-ish>
317-
```
296+
git config --global alias.<handle> <command>
318297

298+
比如:git status 改成 git st,这样可以简化命令
319299

320-
__Alternatives:__
321-
```sh
322-
git branch --contains <commit-ish>
323-
```
324-
325-
## Git Aliases
326-
```sh
327-
git config --global alias.<handle> <command>
328300
git config --global alias.st status
329301
```
330302

331-
## Saving current state of tracked files without commiting
303+
## 存储当前的修改,但不用提交commit
304+
详解可以参考[廖雪峰老师的git教程](http://www.liaoxuefeng.com/wiki/0013739516305929606dd18361248578c67b8067c8c017b000/00137602359178794d966923e5c4134bc8bf98dfb03aea3000)
332305
```sh
333306
git stash
334307
```
335308

336-
337-
__Alternatives:__
309+
## 保存当前状态,包括untracked的文件
310+
untracked文件:新建的文件
338311
```sh
339-
git stash save
312+
git stash -u
340313
```
341314

342-
## Saving current state including untracked files
343-
```sh
344-
git stash save -u
345-
```
346-
347-
348-
__Alternatives:__
349-
```sh
350-
git stash save --include-untracked
351-
```
352-
353-
## Show list of all saved stashes
315+
## 展示所有stashes
354316
```sh
355317
git stash list
356318
```
357319

358-
## Apply any stash without deleting from the stashed list
320+
## 回到某个stash的状态
359321
```sh
360322
git stash apply <stash@{n}>
361323
```
362324

363-
## Apply last stashed state and delete it from stashed list
325+
## 回到最后一个stash的状态,并删除这个stash
364326
```sh
365327
git stash pop
366328
```
367329

368-
369-
__Alternatives:__
370-
```sh
371-
git stash apply stash@{0} && git stash drop stash@{0}
372-
```
373-
374-
## Delete all stored stashes
330+
## 删除所有的stash
375331
```sh
376332
git stash clear
377333
```
378334

379-
380-
__Alternatives:__
381-
```sh
382-
git stash drop <stash@{n}>
383-
```
384-
385-
## Grab a single file from a stash
335+
## 从stash中拿出某个文件的修改
386336
```sh
387337
git checkout <stash@{n}> -- <file_path>
388338
```
389339

390-
391-
__Alternatives:__
392-
```sh
393-
git checkout stash@{0} -- <file_path>
394-
```
395-
396340
## Show all tracked files
397341
```sh
398342
git ls-files -t
@@ -666,11 +610,6 @@ git rebase -i --autosquash
666610
git commit --only <file_path>
667611
```
668612

669-
## Interactive staging.
670-
```sh
671-
git add -i
672-
```
673-
674613
## 展示忽略的文件
675614
```sh
676615
git status --ignored

0 commit comments

Comments
 (0)