
Tips for Intermediate Git Users - pmoriarty
https://www.andyjeffries.co.uk/25-tips-for-intermediate-git-users/
======
iamthebest
This looks like a set of notes that are mostly correct but encourage bad
practices. I think it's because they author doesn't understand git and doesn't
know what they are doing.

>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.

~~~
hueving
>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?

~~~
iamthebest
Yeah. For example:

    
    
      $ 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.

~~~
JoshTriplett
It gets even uglier when you don't discover those conflicts until a pull or
push.

------
stiff
The master tip: have a detailed written policy on git usage, on what goes into
which branch, on git commit message format, and make really, really sure
everyone understands it before they start anything.

No tips will help if the history is crap.

~~~
Fede_V
Is there some kind of git plug in/linter that will check for commit style
before accepting a commit? Basically, linting the commit messages.

~~~
candeira
At my current gig we use a set of git hooks, and the pre-commit hook enforces
the git comment style, which performs integration with
bugtracking/timetracking. We wrote our own and it's just a couple of regexes
tied to a couple of warnings.

Look in any git project's .git/hooks/ directory for some sample scripts.

------
andyjeffries
I replied to an individual comment, but I would just like to comment generally
too - this article is 4 years old and if I wrote the article now there would
have been more advanced information.

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" :-)

------
edem
Just to add some value to this post: [http://ndpsoftware.com/git-
cheatsheet.html](http://ndpsoftware.com/git-cheatsheet.html) This is a
tremendous help for those folks who have not yet reached intermediate level.

~~~
emilng
Thanks! I'm intermediate in some parts of git and not on others, but since I'm
a visual learner this layout really helps me see how the different commands
relate to each other.

------
vowelless
It looks like this is a list to get to you intermediate level in git, as
opposed to tips for already intermediate git users .

I would have liked to see some points about git-bisect, hooks, etc.

~~~
shampine
Agreed. I was expecting more substance in the hooks department, diffs, or
other things off the beaten path. This just seems like a list of the basic git
commands.

------
edem
I find this hardly informative. Those users who consider themselves
intermediate already know all this stuff. When I clicked the link I thought I
will see about interactive rebasing, advanced stashing and stuff like that.
There are other things which are already mentioned by others but the tag
handling advice is horrible. Tags are meant to be immutable milestones. Never
change them and please don't encourage people to do so.

------
VLM
I've found in practice that using "stash" is a very effective way to ensure
you'll spend lots of time in the future looking for a lost branch. I don't
like stash anymore.

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.

------
plesiv
These aliases (from ~/.gitconfig) proved to be invaluable countless times, I
hope someone will find them useful:

    
    
        [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 files

------
swayvil
Am I the only guy who would rather focus on his code?

These days I stash my source in zip files.

------
sledgehammer
Here is a more useful tip:

[http://pastebin.com/RP9ZdZY5](http://pastebin.com/RP9ZdZY5)

~~~
jtreminio
That's nothing but aliases.

------
ExpiredLink
A tip for intermediate and professional users to avoid headaches:
[http://subversion.apache.org/](http://subversion.apache.org/)

~~~
radisb
I am in a cafe and was sipping my coffee when I read your comment. Now people
are looking at me laugh my ass off, with half the coffee spilled on the
keyboard.

