You seem to be asking a very specific question. Now "how do you learn guitar" but "how does an experienced guitarist learn a new piece". To my knowledge there is no "method" or "algorithm" for this. Since everyone is different we may all take different approaches.
The only way my procedure will make sense to anyone is for you to know what I do.
The constraints of THIS algorithm are:
That you can read music.
That you have access to a recording of the piece you want to learn.
They you already have developed some skills on the guitar and can figure out things by ear.
There is more than one scenario for "Learning a new song". As a classical guitarist I may way to put a piece in my performance repertoire. I will do the following.
Get the sheet music.
Find a recording of the piece if it exists, Segovia, Romero, Bream, etc.
I will first assess the quality of the sheet music for arrangement. Are there fingerings? etc. If so then I commence to learning that arrangement. In "learning" the arrangement I aspire to get to a point where the piece is completely memorized. You must be "off book" for this to be a real professional piece. I start by playing through the piece beginning to end in free time, without metronome, not trying to get it perfect but to understand the terrain. Then I pencil in spots that might be challenging. I am assuming that the piece does NOT require a new technique, but if it does then I need to woodshed that technique as part of learning the piece. I commit one phrase, line, or system, to memory each day. Each section (4 or 8 bars depending on the piece) is learnt in isolation from the others. I already have a feel for what is required. Once I have the entire piece memorized in pieces, I try to get through it without looking at the music. After this milestone is reached I start working each small section up to speed with the metronome focusing on different pieces each day but ALWAYS playing the piece from beginning to end slowly as a warm up so I don't forget it. At this point I start listing to recordings to see what tempo others have played it at and what embellishments may have been added. I continue on this path until the entire piece is memorized and can be played up to speed with all dynamics without stopping or getting lost. Then I go off metronome and record myself playing it as if performing. Polish up any weak spots.
As a Rock or Jazz guitarist I might try the same approach but I'd rely more on playing along with the CD or other recorded version of the tune. These styles are usually a bit easier to pick up by ear and the critics more forgiving on improv, and putting your own touch on it. Classical players do this as well but everyone knows the famous arrangements and can identify if you really know it and are embellishing or faking it. That's a tougher crowd. But the same idea applies, isolate parts you understand and can play, consult sheet music or TAB as needed and commit the tune to memory. Be sure you can "play it in your head" and recall everything. This is the only way to ensure expert performance.
Now, if you are asking about what techniques to learn etc. All of them, one at a time. Work up clean speed with the m-nome. This is a life long processes