Git 2.0 changes push default to ‘simple’
blog.nicoschuele.com
blog.nicoschuele.com
Hello? Why wasn't it called "current" instead of "simple"?
Why are these unintuitively named options so frequent in git?
"current" means: push the current branch into a remote branch with the same name, no matter what.
"upstream" means: push the current branch into the upstream branch, that is the remote branch from which you pull the current branch.
"simple" means: push the current branch into the remote branch from which you are pulling, but only if they have the same name. This is supposed to be "more safe" for beginners than the "upstream" mode.
edit: yes. http://stackoverflow.com/questions/10002239/difference-betwe...
"Tracking means that a local branch has its upstream set to a remote branch."
edit two: second question. does 'simple' mean the same as 'upstream' as long as the upstream branch (the one you are tracking from) has the same name as your local branch? I believe so but thought I'd double check.
I have been using git for 4 years. I like it a lot more than svn. I never rebase. I still don't understand some of the things, like why they call it upstream, 'the branch you are pulling from', and tracking, when to me they all seem to mean the same thing.
1. Clone library's master branch, begin using software.
2. Discover problem and commit a fix.
3. Use the Github webui to create a fork of the original repo.
4. git remote rename origin upstream
5. git remote add origin https://github.com/me/awesome-library
6. git push origin master:my-bug-fix
7. Use Github webui to create a pull request from your
my-bug-fix branch into the upstream master.
Having both remotes is necessary, though, when the thing you forked is being actively developed. If there's a review period of a few days, you may need to rebase from the upstream—you want to be doing this from the command line, not bumbling around in the Github webui trying to manage it there.If it were called your "intuitive" name ("current", meaning "this is the current default"), then it would, extremely unintuitively, require renaming if it ever stopped being the default. You would be sacrificing future coherence for the sake of some very mild "intuitive sense" during the present.
Complaining about git's standard porcelain is a popular sport, but so often the people who play it don't give proposals that make more sense than the status quo.
On the other hand, apparently that meaning isn't actually as clear as I'd have guessed, so maybe my intuitions about intuitiveness are off-base.
His proposal seems to be "call whatever happens to be the default 'current'". This of course gets you into a non-intuitive "The king is dead, long live the king" sort of situation.
That said, I disagree with the sentiment, since there is already a 'current' mode to which the 'current' name seems to apply at least equally well.
This is a classic case where the git behavior seems not just unintuitive, but far more complicated than necessary. Why do multiple modes even exist? If I were starting, I'd consider saying that "git push" with no other arguments is the same as what "current" (or even "simple") do now, but you could specify any number of branches or branch wildcards with an argument (including "*"). That is, like ls(1).
I could definitely be missing some important class of use cases, but this feels so much simpler than even having modes, let alone modes that have complex semantics, and still lets the default (very common) case work and supports pushing a manually-specified set of branches, too.
push.default
Defines the action git push should take if no refspec is given on
the command line, no refspec is configured in the remote, and no
refspec is implied by any of the options given on the command line.
Possible values are:
· nothing - do not push anything.
· matching - push all matching branches. All branches having the
same name in both ends are considered to be matching. This is
the default.
· upstream - push the current branch to its upstream branch.
· tracking - deprecated synonym for upstream.
· current - push the current branch to a branch of the same
name.
(yes, my version of git on this machine is out of date)Emphasis on: "if no refspec is given on the command line, no refspec is configured in the remote, and no refspec is implied by any of the options given on the command line"
These modes define what happens if you give no options to git-push. If these modes didn't exist, then you would instead be complaining that a plain old `git push` with no arguments didn't "do what you clearly meant" (where "clearly meant" changes from user to user... particularly since different users have different workflows, some centralized, some not.)
If git-push worked as you suggest, then you would just be complaining that you had to escape your asterisks characters to prevent the shell from expanding them (remember that glob expansion is not something that ls provides...), instead of using a far simpler --all.
You want a legitimate complaint about git-push? Try: "git-add allows either --all or -A, but git-push only allows --all."
You can contact their support and they will enable this for you. They have great support and usually get back to me within a few hours.
If you are behind git warns you and says you need to pull first. By stating -f you are saying nope, throw that crap away and just take my version.
That's pretty extreme and warrants care. I have a hard time feeling sorry for people who are burned by this.
I also just like pushing to a branch on Github, even if I might rebase later. Circle CI is triggered through Github, so it's nice to have that triggered for me. Our staging servers (production data, your branch's code) are deployed from Github branches as well. Plus looking at diffs on Github is really helpful for me to spot errors—I'm not sure if it's the context switch away from my text editor, Github's diff UI, or what, but it works for me.
And that's also unreasonable. Pushed history should be treated as immutable. If you broke the build, push a revert commit, fix the issue, and resubmit. And then fix your tooling to recognize rollbacks.
git push -f
throws away any remote commits (under old behavior).* I made a topic branch and push it for review on github
* I immediately found a trivial typo in my code
* I amended my commit to fix the typo
* I did push -f to overwrite the topic branch on
* OOPS. I pushed all my branches. >.<
It doesn't seem peculiar at all, to me.
Pull is basically the combination of fetch and merge into your local branch. Since there's always a chance for merging to fail and require fixup, it would be dangerous for pull to try all your local branches at once.
It seems that a lot of new git users default to "pull" and I'm not sure why. There must be some really popular tutorial out there that starts with pull.
git checkout origin/interesting-branch
Git will warn you that you're in "detached HEAD" state. When you are making local changes or want to return to where you were, you don't want "git fetch" to have side-effects. Note that you can update local branches without switching to them: git push . origin/branch-name:branch-name
will fast-forward you local 'branch-name' to match 'origin/branch-name'. It's basically the equivalent of git checkout branch-name
git merge --ff-only origin/branch-name # or git pull origin branch-name
git checkout the-last-branch-I-was-on
Each remote has its own namespace for a good reason.Git v2 changes what `git push` does by default: only the current working branch will get pushed to origin.
or rather, every branch that has the same name as a branch on currently tracked remote. I.e. if you're on branch X that tracks remote A, and both you and the remote have branches called Y and Z, even if Y and Z are marked to track B they will be pushed.
pu = -c push.default=simple push -v --progress
pua = -c push.default=matching push -v --progress
poof = -c push.default=simple push -v --progress --force git push origin my-featurePut me in the camp of people who generally prefer explicit over implicit. shrug
Commit messages like "Ugh, I really need to commit more often. Did X, Y, Z, and maybe some other stuff." make me cringe. Those people need this change the most!
It also annoys me when people create a new commit to fix CR feedback instead of amending their non-public commit.
But I agree the '-p' argument is amazing.
http://lwn.net/Articles/131312/
I don't think it really applies to Git as we know it today, though.