Git - GitHub - Collaborating with Git - Part Ⅰ: Remote Work - push, set-upstream
Head First Git: A Learner’s Guide to Understanding Git from the Inside Out、 Raju Gandhi(著)、 O’Reilly Mediaの Chapter 5.(Collaborating with Git - Part Ⅰ: Remote Work)、TEST DRIVE(393/680)の解答を求めてみる。
入出力結果(Terminal, Zsh)
% cd working-with-remotes
working-with-remotes % git branch
feat-a
* master
working-with-remotes % git status
On branch master
Your branch is up to date with 'origin/master'.
nothing to commit, working tree clean
working-with-remotes % git branch feat-b
working-with-remotes % git switch feat-b
Switched to branch 'feat-b'
working-with-remotes % code .
working-with-remotes % git add feat-b-01.md
working-with-remotes % git status
On branch feat-b
Changes to be committed:
(use "git restore --staged <file>..." to unstage)
new file: feat-b-01.md
working-with-remotes % git commit -m 'my first commit on feat-b'
[feat-b 7c1b151] my first commit on feat-b
1 file changed, 1 insertion(+)
create mode 100644 feat-b-01.md
working-with-remotes % git push
fatal: The current branch feat-b has no upstream branch.
To push the current branch and set the remote as upstream, use
git push --set-upstream origin feat-b
To have this happen automatically for branches without a tracking
upstream, see 'push.autoSetupRemote' in 'git help config'.
working-with-remotes % git push --set-upstream origin feat-b
Enumerating objects: 4, done.
Counting objects: 100% (4/4), done.
Delta compression using up to 8 threads
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 304 bytes | 304.00 KiB/s, done.
Total 3 (delta 1), reused 0 (delta 0), pack-reused 0 (from 0)
remote: Resolving deltas: 100% (1/1), completed with 1 local object.
remote:
remote: Create a pull request for 'feat-b' on GitHub by visiting:
remote: https://github.com/kamimura/working-with-remotes/pull/new/feat-b
remote:
To https://github.com/kamimura/working-with-remotes.git
* [new branch] feat-b -> feat-b
branch 'feat-b' set up to track 'origin/feat-b'.
working-with-remotes % git remote
origin
working-with-remotes % git remote -v
origin https://github.com/kamimura/working-with-remotes.git (fetch)
origin https://github.com/kamimura/working-with-remotes.git (push)
working-with-remotes % git switch master
Switched to branch 'master'
Your branch is up to date with 'origin/master'.
working-with-remotes % git status
On branch master
Your branch is up to date with 'origin/master'.
Untracked files:
(use "git add <file>..." to include in what will be committed)
master-04.md
nothing added to commit but untracked files present (use "git add" to track)
working-with-remotes % git add master-04.md
working-with-remotes % git status
On branch master
Your branch is up to date with 'origin/master'.
Changes to be committed:
(use "git restore --staged <file>..." to unstage)
new file: master-04.md
working-with-remotes % git commit -m 'my third commit on master'
[master d9a9714] my third commit on master
1 file changed, 1 insertion(+)
create mode 100644 master-04.md
working-with-remotes % git push
Enumerating objects: 4, done.
Counting objects: 100% (4/4), done.
Delta compression using up to 8 threads
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 319 bytes | 319.00 KiB/s, done.
Total 3 (delta 1), reused 0 (delta 0), pack-reused 0 (from 0)
remote: Resolving deltas: 100% (1/1), completed with 1 local object.
To https://github.com/kamimura/working-with-remotes.git
fc3396b..d9a9714 master -> master
working-with-remotes % git log --oneline --all --graph
* d9a9714 (HEAD -> master, origin/master, origin/HEAD) my third commit on master
| * 7c1b151 (origin/feat-b, feat-b) my first commit on feat-b
|/
* fc3396b Merge branch 'feat-a'
|\
| * 8ccb875 (feat-a) my first commit on feat-a
* | 6780b56 my second commit on master
|/
* 873304c my first commit on master
* 5aefc0d add master-01 file
* f9fd4aa add README
working-with-remotes %