Git - GitHub - Collaborating with Git - Part Ⅰ: Remote Work - push, set-upstream flag, origin
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(415/715)の解答を求めてみる。
入出力結果(Terminal, Zsh)
% git status
On branch master
Your branch is up to date with 'origin/master'.
nothing to commit, working tree clean
% git branch feat-b
% git switch feat-b
Switched to branch 'feat-b'
% echo 'This file is on the feat-b branch.' > feat-b-01.md
% git add feat-b-01.md
% git commit -m 'my first commit on feat-b'
[feat-b fa9cea3] my first commit on feat-b
1 file changed, 1 insertion(+)
create mode 100644 feat-b-01.md
% 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'.
% 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), 345 bytes | 345.00 KiB/s, done.
Total 3 (delta 0), reused 0 (delta 0), pack-reused 0 (from 0)
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'.
% git push
Everything up-to-date
% git switch master
Switched to branch 'master'
Your branch is up to date with 'origin/master'.
% echo 'This is the fourth file on the master branch.' > master-04.md
% git add master-04.md
% git commit -m 'my third-commit on master'
[master a5af7f9] my third-commit on master
1 file changed, 1 insertion(+)
create mode 100644 master-04.md
% 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), 347 bytes | 347.00 KiB/s, done.
Total 3 (delta 0), reused 0 (delta 0), pack-reused 0 (from 0)
To https://github.com/kamimura/working-with-remotes.git
5aefc0d..a5af7f9 master -> master
% git log --oneline --all --graph
* a5af7f9 (HEAD -> master, origin/master, origin/HEAD) my third-commit on master
| * fa9cea3 (origin/feat-b, feat-b) my first commit on feat-b
|/
* 5aefc0d add master-01 file
* f9fd4aa add README
%