が details
subject marker — puts the new information on the noun it follows
あ、バスが来ましたよ。
a, basu ga kimashita yo.
Ah, the bus is here. neutral
弟はピアノが上手です。
otouto wa piano ga jouzu desu.
My younger brother is good at the piano. neutral
Examples
subject — が reports the noun itself as the new part, which is why a question word and the answer to it both take が
あ、バスが来ましたよ。
a, basu ga kimashita yo.
Ah, the bus is here. neutral
え、誰がそんなこと言ったの?
e, dare ga sonna koto itta no?
Huh — who said that? casual
本件につきましては、担当者がのちほどご説明いたします。
honken ni tsukimashite wa, tantousha ga nochihodo go setsumei itashimasu.
On this matter, the person in charge will explain later. formal
the が-object — 好[す]き, 上手[じょうず], 分[わ]かる, ある, 見[み]える and the potential take が where English takes an object
弟はピアノが上手です。
otouto wa piano ga jouzu desu.
My younger brother is good at the piano. neutral
ごめん、この字が読めないんだけど。
gomen, kono ji ga yomenai n da kedo.
Sorry — I can't read this character. casual
the subject inside a relative clause — が, and は cannot get in
これは母が作ったケーキです。
kore wa haha ga tsukutta keeki desu.
This is a cake my mother made. neutral
昨日、姉が撮った写真を見せてもらった。
kinou, ane ga totta shashin o misete moratta.
Yesterday my sister showed me the photos she took. casual
Formation
{N}がattaches to nounAはBが…(象は鼻が長い・私は頭が痛い)attaches to noun phrase (schematic)
Notes
(私の作った料理), a substitution available nowhere else
in the sentence.
Related patterns
Similar
The object flips to が as soon as the predicate turns stative — 日本語を話す but 日本語が分かる and 日本語が上手だ, 水が欲しい; only the -eru potential takes both, where 日本語を話せる is now ordinary and が still reads as the safer, more written choice.
Same slot, opposite jobs — は takes its noun as already settled and puts the news after it (私は行きます answers what I will do), while が puts the news on the noun itself (私が行きます answers who), which is why a question word and the answer to it both take が.
Lookalikes
Two different words spelled が — the case particle binds a NOUN to its predicate (雨が降る), the conjunction sits after a finished clause and turns it (行きましたが、閉まっていました); the test is substitution, since only the conjunction swaps for けれど.
Combines with
〜のが好きだ is this が with a nominalised clause in the noun position — の packages 泳ぐ into a thing first, because が binds nouns and never a bare verb.
欲しい is an adjective, so what English calls its object stays a が-subject (水が欲しい) — and the derived verb 欲しがる flips it straight back to を, since that one really is a verb.
ことができる runs on the same が: こと nominalises the action so できる can take it as its subject, which is the mechanism behind the potential flipping its object from を to が.