Check Which Branch Is Checked Out
sbogb$ git branch
* bootstrap
master
Set The Upstream To The Original Author’s Repo and Specific Branch
sbogb$ git remote add -t bootstrap origin-readonly https://github.com/qdouble/angular-webpack2-starter.git
Break the Push to the Source Repo To Make It Clear We Can Not Push
sbogb$ git remote set-url origin-readonly --push "You shall not push"
Fetch the Source Repo/Branch Into The Local Branch
sbogb$ git fetch origin-readonly bootstrap
From https://github.com/qdouble/angular-webpack2-starter
* branch bootstrap -> FETCH_HEAD
* [new branch] bootstrap -> origin-readonly/bootstrap
Add a Remote Named origin
to the master
Branch
sbogb$ git remote add -t master origin ssh://git-codecommit.us-east-2.amazonaws.com/v1/repos/angular-webpack2-bootstrap-starter
Set GIT to Only Push the Current Branch
sbogb$ git config --global push.default simple
First Push of the Current Branch
sbogb$ git push --set-upstream origin master
Warning: Permanently added the RSA host key for IP address '192.168.18.123' to the list of known hosts.
Counting objects: 1431, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (479/479), done.
Writing objects: 100% (1431/1431), 468.41 KiB | 0 bytes/s, done.
Total 1431 (delta 928), reused 1425 (delta 924)
To ssh://git-codecommit.us-east-2.amazonaws.com/v1/repos/angular-webpack2-bootstrap-starter
* [new branch] master -> master
Branch master set up to track remote branch master from origin.
Other: Remove A Remote origin
sbogb$ git remote add -t master origin ssh://git-codecommit.us-east-2.amazonaws.com/v1/repos/angular-webpack2-bootstrap-starter
fatal: remote origin already exists.
sbogb$ git remote remove origin
sbogb$
Other: Multiple Upstreams Require Choosing the Upstream
sbogb$ git push
warning: push.default is unset; its implicit value has changed in
Git 2.0 from 'matching' to 'simple'. To squelch this message
and maintain the traditional behavior, use:
git config --global push.default matching
To squelch this message and adopt the new behavior now, use:
git config --global push.default simple
When push.default is set to 'matching', git will push local branches
to the remote branches that already exist with the same name.
Since Git 2.0, Git defaults to the more conservative 'simple'
behavior, which only pushes the current branch to the corresponding
remote branch that 'git pull' uses to update the current branch.
See 'git help config' and search for 'push.default' for further information.
(the 'simple' mode was introduced in Git 1.7.11. Use the similar mode
'current' instead of 'simple' if you sometimes use older versions of Git)
fatal: The current branch master has no upstream branch.
To push the current branch and set the remote as upstream, use
git push --set-upstream origin master
Other: First Push to Upstream will Require Remote
sbogb$ git push
fatal: The current branch master has no upstream branch.
To push the current branch and set the remote as upstream, use
git push --set-upstream origin master