計算機科学のブログ

ほしい物リスト

Git - GitHub - Searching Git Repositories - Git a Grep - commit id, checkout

Head First Git: A Learner’s Guide to Understanding Git from the Inside OutRaju Gandhi(著)、 O’Reilly Mediaの Chapter 7.(Searching Git Repositories: Git a Grep)、EXERCISE(564/680)の解答を求めてみる。

入出力結果(Terminal, Zsh)

% git branch
* master
% git status
On branch master
Your branch is up to date with 'origin/master'.

nothing to commit, working tree clean
% ls
README.md	appetizers.md	dinner.md	drinks.md
% git checkout 99fd56e
Note: switching to '99fd56e'.

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 99fd56e add first draft of appetizer and drink menus
% ls
README.md	appetizers.md	drinks.md
% git status
HEAD detached at 99fd56e
nothing to commit, working tree clean
% git branch
* (HEAD detached at 99fd56e)
  master
% git log --oneline --all --graph 
* 7886bce (origin/master, origin/HEAD, master) add two more appetizers
* 0b90575 offer nonalcoholic options
* c366817 remove Git puns and make drinks more seasonal
* e9beff3 remove nuts from all items due to allergy concerns
* b6c8c82 replace meat dishes with vegetarian items
* d36c983 add first draft of dinner menu
* 99fd56e (HEAD) add first draft of appetizer and drink menus
* 6b11ec8 add README
%