Tips for Intermediate Git Users
andyjeffries.co.uk
andyjeffries.co.uk
>A lightweight tag is simply a named pointer to a commit. You can always change it to point to another commit.
Umm, you can do this, but in general you should never rename tags. Occasionally a developer will tell me the tag they pushed is incorrect and I'll agree to remove it only if they promise not to re-create it. If you read the man page on git-tag it's clear why you should avoid doing this.
>A lovely little tip – don’t forget that branch names aren’t limited to a-z and 0-9. It can be quite nice to use / and . in names for fake namespacing
If you use '/' is branch names you can create path conflicts. I've seen it happen and it took me a day to debug and figure out. There is some code checking for path conflicts in the git source but it's not invoked via all code paths that create branches. I recommend against using slashes in branch names unless you know what you are doing.
Can you elaborate on this? What you said doesn't make much sense. If having a slash in the branch name creates path conflicts, that means slashes are treated specially, right? How exactly does someone 'know what they are doing' to be able to use them?
$ git branch fireos
$ git branch fireos/feature-branch
error: unable to create directory for .git/refs/heads/fireos/feature-branch
fatal: Failed to lock ref for update: No such file or directory
This happens because creating 'fireos' branch stores the sha1 in file .git/refs/heads/fireos. But if you later want to create branch 'fireos/feature-branch', git needs to store the sha1 in .git/refs/heads/fireos/feature-branch. This is impossible because 'fireos' is a file and cannot be a directory. Path conflict.But its a global policy so "wp" and "wp/BTS-number" will always be a folder, and conflicts should never happen.
I'll take your word for it, but the git man pages are notoriously unreadable. They might be useful for a git guru, but for someone that is learning the commands they are downright harmful.
[0] https://www.kernel.org/pub/software/scm/git/docs/git-tag.htm...
Can you elaborate? I'm definitely not a git guru and I always read the man pages, and I find them quite readable. It's also the first place I learn best practices from.
Listing every option with a description, to me, is not as useful as seeing it in practice.
Of course, we might have issues if we named a branch `feature` or `hotfix`, but that's never been an issue for us.
You could say the same thing about filesystems though. Not sure this is an issue.
Thanks for your kind comment...
I would like to point out that this article is over 4 years old (hence my knowledge will have increased since then) and it was also basically my notes on our training with Scott Chacon of GitHub. I'm sure you wouldn't consider him to not "know what [he is] doing". Maybe it reflected best practices at the time the training was delivered and the article was written.
Anyway, I appreciate it's resurgence in popularity...
No tips will help if the history is crap.
Look in any git project's .git/hooks/ directory for some sample scripts.
An example for jquery style commits is https://www.npmjs.com/package/commitplease
So there should actually be a history of histories :) Perhaps something for the git team to pick up...
[1]: http://mercurial.selenic.com/wiki/ChangesetEvolution [2]: https://hglabhq.com/blog/2014/4/29/what-s-new-in-mercurial-3...
At the time beginners in git weren't doing much of this stuff, so they were tips for people who had used git daily, but this stuff wasn't common knowledge being done by all developers.
If anyone has anything they'd like to see in an advanced article, let me know and maybe I'll consider writing a "Tips for becoming an Advanced Git User" :-)
I would have liked to see some points about git-bisect, hooks, etc.
I like the idea of aliasing the command unstage, but once "reset HEAD" is in the muscle memory its kinda stuck.
Is git-flow still cool? Or is it so popular its just assumed to be in use as a standard, thus well beneath the level of an "intermediate" users guide? If you don't use "the" git flow repo, at least as a branch naming strategy and overall usage strategy it's worked pretty well for me.
[alias]
logo = log --oneline --graph --all --decorate
logg = log --graph --all --decorate
logt = log --date-order --graph --tags --simplify-by-decoration --pretty=format:'%ai %h %C(Yellow)%d%Creset'
ignored = ls-files --others -i --exclude-standard
Explanation: logo, logg - improved logs
logt - log just tagged commits
ignored - lists ignored filesThese days I stash my source in zip files.