Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add examples from the common screwups resource in #40 #175

Merged
merged 2 commits into from
Dec 20, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 35 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,12 +80,15 @@ For clarity's sake all examples in this document use a customized bash prompt in
- [Finding](#finding)
- [I want to find a string in any commit](#i-want-to-find-a-string-in-any-commit)
- [I want to find by author/committer](#i-want-to-find-by-authorcommitter)
- [Miscellaneous Objects](#miscellaneous-objects)
- [Submodules](#submodules)
- [Clone all submodules](#clone-all-submodules)
- [Remove a submodule](#remove-a-submodule)
- [Miscellaneous Objects](#miscellaneous-objects)
- [Restore a deleted file](#restore-a-deleted-file)
- [Delete tag](#delete-tag)
- [Recover a deleted tag](#recover-a-deleted-tag)
- [Deleted Patch](#deleted-patch)
- [Exporting a repository as a Zip file](#exporting-a-repository-as-a-zip-file)
- [Tracking Files](#tracking-files)
- [I want to change a file name's capitalization, without changing the contents of the file](#i-want-to-change-a-file-names-capitalization-without-changing-the-contents-of-the-file)
- [I want to overwrite local files when doing a git pull](#i-want-to-overwrite-local-files-when-doing-a-git-pull)
Expand Down Expand Up @@ -117,12 +120,18 @@ Let's say that you just blindly committed changes with `git commit -a` and you'r
(master)$ git show
```

or
Or

```sh
$ git log -n1 -p
```

If you want to see a file at a specific commit, you can also do this (where `<commitid>` is the commit you're interested in):

```sh
$ git show <commitid>:filename
```

<a name="#i-wrote-the-wrong-thing-in-a-commit-message"></a>
### I wrote the wrong thing in a commit message

Expand Down Expand Up @@ -1156,8 +1165,7 @@ $ git log --committer=<name or email>

Keep in mind that author and committer are not the same. The `--author` is the person who originally wrote the code; on the other hand, the `--committer`, is the person who committed the code on behalf of the original author.

<a name="miscellaneous-objects"></a>
## Miscellaneous Objects
## Submodules

<a name="clone-submodules"></a>
### Clone all submodules
Expand All @@ -1184,6 +1192,23 @@ $ git rm --cached submodulename
$ rm -rf .git/modules/submodulename
```

<a name="miscellaneous-objects"></a>
## Miscellaneous Objects

### Restore a deleted file

First find the commit when the file last existed:

```sh
$ git rev-list -n 1 HEAD -- filename
```

Then checkout that file:

```
git checkout deletingcommitid^ -- filename
```

<a name="delete-tag"></a>
### Delete tag

Expand Down Expand Up @@ -1220,6 +1245,12 @@ From github.com:foo/bar
* [new ref] refs/pull/1/head -> pr_1
```

### Exporting a repository as a Zip file

```sh
$ git archive --format zip --output /full/path/to/zipfile.zip master
```

## Tracking Files

<a href="i-want-to-change-a-file-names-capitalization-without-changing-the-contents-of-the-file"></a>
Expand Down