这是indexloc提供的服务,不要输入任何密码
Skip to content
Merged
Show file tree
Hide file tree
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
5 changes: 5 additions & 0 deletions pro-git/chapter-02/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,8 @@
- [Annotated Tags](tagging.md#annotated-tags)
- [Lightweight Tags](tagging.md#lightweight-tags)
- [Tagging Later](tagging.md#tagging-later)
- [Sharing Tags](tagging.md#sharing-tags)
- [To Push a Specific Tag to a Remote Repository](tagging.md#to-push-a-specific-tag-to-a-remote-repository)
- [To Push All Tags to a Remote Repository (in Cases Where There Are a Lot of Tags to Push Manually)](tagging.md#to-push-all-tags-to-a-remote-repository-in-cases-where-there-are-a-lot-of-tags-to-push-manually)
- [Deleting Tags](tagging.md#deleting-tags)
- [Checking Out Tags](tagging.md#checking-out-tags)
8 changes: 8 additions & 0 deletions pro-git/chapter-02/commit-history.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
- [Checking Commit History](#checking-commit-history)
- [`git log`](#git-log)
- [`git log --patch -<n>`](#git-log---patch--n)
- [`git log --stat`](#git-log---stat)
- [`git log --pretty=<option>`](#git-log---prettyoption)
- [Combining the `--pretty` option with the `--graph` option](#combining-the---pretty-option-with-the---graph-option)
- [Common options to `git-log`](#common-options-to-git-log)

## Checking Commit History

> [!TIP]
Expand Down
3 changes: 3 additions & 0 deletions pro-git/chapter-02/diff-rm.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
- [Compare Changes Made with `git diff`](#compare-changes-made-with-git-diff)
- [Removing Files from the Staging Area, but Retaining in the Working Directory](#removing-files-from-the-staging-area-but-retaining-in-the-working-directory)

## Compare Changes Made with `git diff`

Use `git status` as a primer for this:
Expand Down
4 changes: 4 additions & 0 deletions pro-git/chapter-02/ignoring-files.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
- [Ignoring Files](#ignoring-files)
- [Glob patterns](#glob-patterns)
- [Example `.gitignore` file\[^2\]](#example-gitignore-file2)

## Ignoring Files

Rules of `.gitignore` files:
Expand Down
5 changes: 5 additions & 0 deletions pro-git/chapter-02/log-output.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
- [Limiting Log Output](#limiting-log-output)
- [`git log --since=<n>`](#git-log---sincen)
- [`git log -S <string>`](#git-log--s-string)
- [Common options to limit output to `git-log`](#common-options-to-limit-output-to-git-log)

## Limiting Log Output

> [!TIP]
Expand Down
7 changes: 7 additions & 0 deletions pro-git/chapter-02/remotes.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
- [Working with Remotes](#working-with-remotes)
- [Showing Your Remotes](#showing-your-remotes)
- [Adding Remotes](#adding-remotes)
- [Fetching and Pulling from Your Remotes](#fetching-and-pulling-from-your-remotes)
- [Inspecting a Remote](#inspecting-a-remote)
- [Renaming and Removing Remotes](#renaming-and-removing-remotes)

## Working with Remotes

### Showing Your Remotes
Expand Down
116 changes: 115 additions & 1 deletion pro-git/chapter-02/tagging.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
- [Tagging](#tagging)
- [Listing your Tags](#listing-your-tags)
- [Creating Tags](#creating-tags)
- [Annotated tags](#annotated-tags)
- [Lightweight tags](#lightweight-tags)
- [Tagging Later](#tagging-later)
- [Sharing Tags](#sharing-tags)
- [To push a specific tag to a remote repository](#to-push-a-specific-tag-to-a-remote-repository)
- [To push all tags to a remote repository (in cases where there are a lot of tags to push manually)](#to-push-all-tags-to-a-remote-repository-in-cases-where-there-are-a-lot-of-tags-to-push-manually)
- [Deleting Tags](#deleting-tags)
- [Checking out Tags](#checking-out-tags)

## Tagging

### Listing your Tags
Expand Down Expand Up @@ -151,4 +163,106 @@ Date: Mon Nov 11 10:05:14 2024 +1100

### Sharing Tags

TODO: TBC
Run `git tag` to show existing tags:

```shell
git tag
```

```shell
v1.0
v1.4
v1.4-lw
```

#### To push a specific tag to a remote repository

```shell
git push origin <tag>
```

```shell
git push origin v1.4

Enumerating objects: 1, done.
Counting objects: 100% (1/1), done.
Writing objects: 100% (1/1), 225 bytes | 225.00 KiB/s, done.
Total 1 (delta 0), reused 0 (delta 0), pack-reused 0 (from 0)
To github.com:jusuchin85/fuzzy-waffle.git
* [new tag] v1.4 -> v1.4
```

#### To push all tags to a remote repository (in cases where there are a lot of tags to push manually)

```shell
git push origin --tags
```

```shell
Enumerating objects: 1, done.
Counting objects: 100% (1/1), done.
Writing objects: 100% (1/1), 234 bytes | 234.00 KiB/s, done.
Total 1 (delta 0), reused 0 (delta 0), pack-reused 0 (from 0)
To github.com:jusuchin85/fuzzy-waffle.git
* [new tag] v1.0 -> v1.0
* [new tag] v1.4-lw -> v1.4-lw
```

> [!NOTE]
> `git push <remote> --tags` will push all of your tags — both lightweight and annotated — to a remote repository. If you don't want to push your lightweight tags, you can use the `--follow-tags` option to only push annotated tags.

### Deleting Tags

To delete a tag, you can run the `git tag --delete <tag>` command:

```shell
git tag --delete v1.4-lw

Deleted tag 'v1.4-lw' (was 05c9df4)
```

This only deletes the tag on your local repository. To delete the tag on the remote repository, use the `git push origin --delete <tag>` command:

```shell
git push origin --delete v1.4-lw

To github.com:jusuchin85/fuzzy-waffle.git
- [deleted] v1.4-lw
```

### Checking out Tags

Checking out tags is similar to switching a branch (using the `git checkout <tag>` command); though this would place your repository in a "detached HEAD" state. This is because you will be checking out a specific commit, and not a branch. To check out a tag, you can run the following command:

```shell
git checkout v1.0
```

```shell
Note: switching to 'v1.0'.

You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by switching back to a branch.

If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -c with the switch command. Example:

git switch -c <new-branch-name>

Or undo this operation with:

git switch -

Turn off this advice by setting config variable advice.detachedHead to false

HEAD is now at 093b2f8 Initial commit
```

This workflow is not typically executed, unless in circumstances where you want to raise a commit against the specific version (like a hotfix). In such cases, you can create a new branch from the tag and raise your commit there:

```shell
git checkout -b <branch> <tag>

Switched to a new branch 'hotfix-1.0'
```
5 changes: 5 additions & 0 deletions pro-git/chapter-02/undoing.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
- [Undoing Things](#undoing-things)
- [Amending the Last Commit](#amending-the-last-commit)
- [Unstaging a Staged File](#unstaging-a-staged-file)
- [Unmodifying a Modified File](#unmodifying-a-modified-file)

## Undoing Things

### Amending the Last Commit
Expand Down