計算機科学のブログ

ほしい物リスト

Git - GitHub - Collaborating with Git - Ⅱ: Go, Team, Go! - branch, fetch, switch, add, commit

Head First Git: A Learner’s Guide to Understanding Git from the Inside OutRaju Gandhi(著)、 O’Reilly Mediaの Chapter 6.(Collaborating with Git - Ⅱ: Go, Team, Go!)、SHARPeN YOUR PENCIL(469/680)の解答を求めてみる。

入出力結果(Terminal, Zsh)

% cd addisons-clone 
addisons-clone % git status 
On branch addison-add-faqs
Your branch is up to date with 'origin/addison-add-faqs'.

nothing to commit, working tree clean
addisons-clone % git branch
* addison-add-faqs
  master
addisons-clone % git branch -v
* addison-add-faqs c3542a0 add second FAQ
  master           b278f04 addison's first commit
addisons-clone % git branch -vv
* addison-add-faqs c3542a0 [origin/addison-add-faqs] add second FAQ
  master           b278f04 [origin/master] addison's first commit
addisons-clone % git branch --all             
* addison-add-faqs
  master
  remotes/origin/HEAD -> origin/master
  remotes/origin/addison-add-faqs
  remotes/origin/master
  remotes/origin/sangita-add-profile
addisons-clone % git switch sangita-add-profile 
branch 'sangita-add-profile' set up to track 'origin/sangita-add-profile'.
Switched to a new branch 'sangita-add-profile'
addisons-clone % git branch
  addison-add-faqs
  master
* sangita-add-profile
addisons-clone % git branch -v
  addison-add-faqs    c3542a0 add second FAQ
  master              b278f04 addison's first commit
* sangita-add-profile 2350fc1 add sample profile
addisons-clone % git branch -vv
  addison-add-faqs    c3542a0 [origin/addison-add-faqs] add second FAQ
  master              b278f04 [origin/master] addison's first commit
* sangita-add-profile 2350fc1 [origin/sangita-add-profile] add sample profile
addisons-clone % git status    
On branch sangita-add-profile
Your branch is up to date with 'origin/sangita-add-profile'.

nothing to commit, working tree clean
addisons-clone % git branch -vv       
  addison-add-faqs    c3542a0 [origin/addison-add-faqs] add second FAQ
  master              b278f04 [origin/master] addison's first commit
* sangita-add-profile 2350fc1 [origin/sangita-add-profile] add sample profile
addisons-clone % cp ../../headfirst-git-samples/chapter06/Profile-2.md Profile.md 
addisons-clone % git status
On branch sangita-add-profile
Your branch is up to date with 'origin/sangita-add-profile'.

Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git restore <file>..." to discard changes in working directory)
	modified:   Profile.md

no changes added to commit (use "git add" and/or "git commit -a")
addisons-clone % git add Profile.md 
addisons-clone % git status  
On branch sangita-add-profile
Your branch is up to date with 'origin/sangita-add-profile'.

Changes to be committed:
  (use "git restore --staged <file>..." to unstage)
	modified:   Profile.md

addisons-clone % git commit -m 'update profile'
[sangita-add-profile a055631] update profile
 1 file changed, 2 insertions(+)
addisons-clone % git status
On branch sangita-add-profile
Your branch is ahead of 'origin/sangita-add-profile' by 1 commit.
  (use "git push" to publish your local commits)

nothing to commit, working tree clean
addisons-clone % git log --oneline --all --graph 
* a055631 (HEAD -> sangita-add-profile) update profile
* 2350fc1 (origin/sangita-add-profile) add sample profile
| * c3542a0 (origin/addison-add-faqs, addison-add-faqs) add second FAQ
|/  
* b278f04 (origin/master, origin/HEAD, master) addison's first commit
* 32b1d92 add README
addisons-clone % git branch -vv
  addison-add-faqs    c3542a0 [origin/addison-add-faqs] add second FAQ
  master              b278f04 [origin/master] addison's first commit
* sangita-add-profile a055631 [origin/sangita-add-profile: ahead 1] update profile
addisons-clone %