git push remote-name some-name
attempts to push any local branch named some-name
to a remote branch also named some-name
resolved at remote-name/some-name
. Under the hood, it's looking for branch names under refs
at each location (local, remote) that match.
Since your local copy of development
hasn't been modified, you get a message that it's up to date, nothing to push.
The alternate version
git push remote-name HEAD:development
skips the part about looking for matching branch names in local and remote refs
because you've given it an explicit branch via HEAD
.
It still does use remote refs
to determine the remote branch development
. But then it uses HEAD
of the current branch (your new test
branch) for the commits to be pushed.
If you want to simply do git push
from test
branch and correctly push from test
to remote/development
, you can configure the default behavior of push
to the "upstream" setting (note that the term "tracking" is an older term for "upstream" which is preferred).
Do
git config --global push.default upstream
to ensure that a plain git push
will only attempt to push from the current branch to its registered upstream branch.
Without the setting, prior to git version 2.0, the default mode for a plain git push
results in attempting to push all local branches to upstream branches with matching names at their configured remotes. For git 2.0 and newer, the default setting is simple
which acts like upstream
except that it also fails to push if the current branch doesn't share the same name as its configured remote.
The "upstream" setting is a good one because (a) it allows easily pushing branches regardless of whether their names match to their upstream names; (b) for versions prior to 2.0, it restricts a bare invocation of git push
to affecting only the current branch, so if you're actively developing on multiple branches, git push
will no longer unintentionally push other work unrelated to current branch work; (c) you will not need the form of git push that specifically names the remote and branch unless you're attempting to push to some branch that is not the configured upstream for your current branch -- and I'd argue this makes the most sense: you should only need to verbosely spell out the branches if you're not pushing from a local branch to its natural, configured upstream target. Even the 2.0 simple
setting doesn't satisfy this.
remote-name
is often origin
, but can be any configured remote, added via various git commands or directly as in a .gitconfig file.