<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title>Git on KLJ docs</title>
		<link>https://diary.klj.mywire.org/docs/git-backup/</link>
		<description>Recent content in Git on KLJ docs</description>
		<generator>Hugo</generator>
		<language>en</language>
		
		
		
		
			<atom:link href="https://diary.klj.mywire.org/docs/git-backup/index.xml" rel="self" type="application/rss+xml" />
			<item>
				<title>Käsitteet: main, branch, origin ja muut</title>
				<link>https://diary.klj.mywire.org/docs/git-backup/kasitteet/</link>
				<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
				<guid>https://diary.klj.mywire.org/docs/git-backup/kasitteet/</guid>
				<description>&lt;p&gt;Gitissä on muutama peruskäsite, jotka kannattaa sisäistää, koska ne selittävät &lt;em&gt;miksi&lt;/em&gt; komennot toimivat kuten toimivat.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Repository (repo)&lt;/strong&gt; on projektikansio, jossa on Git-historia mukana. Repo sisältää sekä tiedostot että &lt;code&gt;.git/&lt;/code&gt;-hakemiston, jossa Git säilyttää kaiken versionhallintatiedon.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Commit&lt;/strong&gt; on pysyvä “tallennuspiste” projektin historiassa. Commit sisältää viittauksen edelliseen committiin sekä muutokset (diffit) siihen hetkeen asti. Kun teet commitin, annat yleensä viestin (esim. “Lisätty uusi artikkeli”).&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Branch&lt;/strong&gt; (haara) on käytännössä nimi, joka osoittaa tiettyyn commitin “kärkeen” (latest commit). Kun teet uusia committeja branchiin, branchin osoitin liikkuu eteenpäin. Brancheilla kehität ominaisuuksia erillään, ilman että päähaara sotkeentuu.&lt;/p&gt;</description>
			</item>
			<item>
				<title>Käyttöönotto Hugo-projektissa</title>
				<link>https://diary.klj.mywire.org/docs/git-backup/02-alku/</link>
				<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
				<guid>https://diary.klj.mywire.org/docs/git-backup/02-alku/</guid>
				<description>&lt;h2 id=&#34;asennus-ja-asetukset&#34;&gt;Asennus ja asetukset&lt;/h2&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-bash&#34; data-lang=&#34;bash&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;git --version&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;git config --global user.name &lt;span style=&#34;color:#4e9a06&#34;&gt;&amp;#34;Etunimi Sukunimi&amp;#34;&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;git config --global user.email &lt;span style=&#34;color:#4e9a06&#34;&gt;&amp;#34;sahkoposti@example.com&amp;#34;&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;git config --global --list&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;&lt;strong&gt;Repo käyttöön (git init)&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;Siirry Hugo-projektin juureen:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-bash&#34; data-lang=&#34;bash&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#204a87&#34;&gt;cd&lt;/span&gt; polku/hugo-projekti&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;git init&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;&lt;strong&gt;.gitignore (suositus Hugolle)&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;Luo .gitignore projektin juureen:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-bash&#34; data-lang=&#34;bash&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;/public/&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;/resources/_gen/&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;.DS_Store&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;.vscode/&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;.idea/&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;*.swp&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;*~&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Ensimmäinen commit&#xA;git add .&#xA;git commit -m &amp;ldquo;Initial commit&amp;rdquo;&lt;/p&gt;&#xA;&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;&#xA;---&#xA;&#xA;# 4) `content/docs/git/03-peruskomennot.md`&#xA;&#xA;```md&#xA;---&#xA;title: &amp;#34;Peruskomennot arkeen&amp;#34;&#xA;weight: 13&#xA;---&#xA;&#xA;## Tilanne ja historia&#xA;&#xA;```bash&#xA;git status&#xA;git log --oneline --decorate --graph --all&#xA;&#xA;Muutosten katselu&#xA;git diff&#xA;git diff --staged&#xA;&#xA;Lisää ja committaa&#xA;&#xA;Lisää yksittäinen tiedosto:&#xA;&#xA;git add content/posts/uusi-postaus.md&#xA;&#xA;&#xA;Lisää kaikki:&#xA;&#xA;git add .&#xA;&#xA;&#xA;Commit:&#xA;&#xA;git commit -m &amp;#34;Lisätty uusi postaus&amp;#34;&#xA;&#xA;&#xA;Pikakommit (vain jo seurattuihin tiedostoihin):&#xA;&#xA;git commit -am &amp;#34;Päivitetty tekstejä&amp;#34;&#xA;&#xA;Stash (laita keskeneräinen työ sivuun)&#xA;git stash&#xA;# tee jotain muuta, esim. vaihda branchia&#xA;git stash pop&#xA;&#xA;&#xA;---&#xA;&#xA;# 5) `content/docs/git/04-github.md`&#xA;&#xA;```md&#xA;---&#xA;title: &amp;#34;GitHub: tallennus, kloonaus ja päivitys&amp;#34;&#xA;weight: 14&#xA;---&#xA;&#xA;## Tallenna projekti GitHubiin (remote + push)&#xA;&#xA;1) Luo repo GitHubissa (New repository).  &#xA;2) Kytke paikallinen repo remoteen:&#xA;&#xA;```bash&#xA;git remote add origin git@github.com:KAYTTAJA/hugo-sivusto.git&#xA;git remote -v&#xA;&#xA;&#xA;Jos haluat käyttää HTTPS:ää:&#xA;&#xA;git remote add origin https://github.com/KAYTTAJA/hugo-sivusto.git&#xA;&#xA;&#xA;Varmista branchin nimi (main):&#xA;&#xA;git branch&#xA;git branch -m main  # jos se oli master ja haluat main&#xA;&#xA;&#xA;Lähetä GitHubiin:&#xA;&#xA;git push -u origin main&#xA;&#xA;&#xA;Jatkossa:&#xA;&#xA;git push&#xA;&#xA;Kloonaa projekti GitHubista (clone)&#xA;cd minne/haluat/projektin&#xA;git clone git@github.com:KAYTTAJA/hugo-sivusto.git&#xA;cd hugo-sivusto&#xA;&#xA;Päivitä omalle koneelle (pull vs fetch)&#xA;&#xA;Hae ja yhdistä:&#xA;&#xA;git pull&#xA;&#xA;&#xA;Hae ilman yhdistämistä:&#xA;&#xA;git fetch&#xA;git log --oneline --decorate --graph --all&#xA;&#xA;&#xA;---&#xA;&#xA;# 6) `content/docs/git/05-branch-merge.md`&#xA;&#xA;```md&#xA;---&#xA;title: &amp;#34;Branchit ja merge&amp;#34;&#xA;weight: 15&#xA;---&#xA;&#xA;## Miksi branchit?&#xA;&#xA;Pidä `main` siistinä ja julkaisukelpoisena. Tee työ omissa brancheissa (esim. `feature/uusi-sivu`), ja yhdistä kun valmista.&#xA;&#xA;## Luo branch ja vaihda siihen&#xA;&#xA;```bash&#xA;git switch -c feature/uusi-sivu&#xA;&#xA;&#xA;Listaa branchit:&#xA;&#xA;git branch&#xA;&#xA;&#xA;Vaihda takaisin mainiin:&#xA;&#xA;git switch main&#xA;&#xA;Pushaa branch GitHubiin&#xA;git push -u origin feature/uusi-sivu&#xA;&#xA;Merge (yhdistä feature → main)&#xA;&#xA;Tyypillinen kaava:&#xA;&#xA;git switch main&#xA;git pull&#xA;git merge feature/uusi-sivu&#xA;git push&#xA;&#xA;Merge-konfliktit&#xA;&#xA;Jos Git ilmoittaa konfliktista:&#xA;&#xA;Katso tiedostot:&#xA;&#xA;git status&#xA;&#xA;&#xA;Avaa konfliktitiedosto ja etsi merkinnät:&#xA;&#xA;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt; HEAD&#xA;mainin versio&#xA;=======&#xA;feature-branchin versio&#xA;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt; feature/uusi-sivu&#xA;&#xA;&#xA;Päätä lopullinen sisältö ja poista merkkirivit&#xA;&#xA;Lisää ja committaa:&#xA;&#xA;git add polku/tiedosto.md&#xA;git commit -m &amp;#34;Resolve merge conflict&amp;#34;&#xA;&#xA;Branchin poisto&#xA;&#xA;Paikallinen:&#xA;&#xA;git branch -d feature/uusi-sivu&#xA;&#xA;&#xA;Etäbranch:&#xA;&#xA;git push origin --delete feature/uusi-sivu&#xA;&#xA;&#xA;---&#xA;&#xA;# 7) `content/docs/git/06-palautus.md`&#xA;&#xA;```md&#xA;---&#xA;title: &amp;#34;Palautus ja peruutus&amp;#34;&#xA;weight: 16&#xA;---&#xA;&#xA;## Palauta tiedosto (ennen committia)&#xA;&#xA;Peru muokkaus tiedostosta:&#xA;&#xA;```bash&#xA;git restore content/posts/juttu.md&#xA;&#xA;&#xA;Jos se on jo staged:&#xA;&#xA;git restore --staged content/posts/juttu.md&#xA;git restore content/posts/juttu.md&#xA;&#xA;&#xA;Palauta kaikki muutokset:&#xA;&#xA;git restore .&#xA;&#xA;Peruuta commit turvallisesti (revert)&#xA;&#xA;revert tekee uuden commitin, joka kumoaa vanhan — hyvä valinta, jos olet jo pushaanut GitHubiin.&#xA;&#xA;git log --oneline&#xA;git revert &amp;lt;commit-id&amp;gt;&#xA;git push&#xA;&#xA;Reset (varo)&#xA;&#xA;Kova reset voi hävittää paikallisia muutoksia/committeja:&#xA;&#xA;git reset --hard &amp;lt;commit-id&amp;gt;&#xA;&#xA;&#xA;Jos olet jo pushaanut ja muutat historiaa, joudut joskus käyttämään force pushia (yleensä vältettävä tiimeissä).&#xA;&#xA;&#xA;---&#xA;&#xA;# 8) `content/docs/git/07-submodulit.md`&#xA;&#xA;```md&#xA;---&#xA;title: &amp;#34;Hugo-teemat ja submodulet (valinnainen)&amp;#34;&#xA;weight: 17&#xA;---&#xA;&#xA;Jos teema on lisätty Git submodulella, kloonauksen jälkeen tarvitset tämän:&#xA;&#xA;```bash&#xA;git submodule update --init --recursive&#xA;&#xA;&#xA;Päivitä submodule (jos haluat uusimman version remote-haarasta):&#xA;&#xA;git submodule update --remote --merge&#xA;git add .&#xA;git commit -m &amp;#34;Update theme submodule&amp;#34;&#xA;git push&#xA;&#xA;&#xA;Jos et käytä submodulea, voit ohittaa tämän sivun.&#xA;&#xA;&#xA;---&#xA;&#xA;# 9) `content/docs/git/99-cheatsheet.md`&#xA;&#xA;```md&#xA;---&#xA;title: &amp;#34;Cheatsheet&amp;#34;&#xA;weight: 99&#xA;---&#xA;&#xA;## Päivittäinen käyttö&#xA;&#xA;```bash&#xA;git status&#xA;git add .&#xA;git commit -m &amp;#34;viesti&amp;#34;&#xA;git push&#xA;git pull&#xA;&#xA;Branchit&#xA;git switch -c feature/juttu&#xA;git switch main&#xA;git merge feature/juttu&#xA;&#xA;Tutki historiaa&#xA;git log --oneline --graph --decorate --all&#xA;git diff&#xA;git diff --staged&#xA;&#xA;Palautus&#xA;git restore tiedosto&#xA;git revert &amp;lt;commit-id&amp;gt;&#xA;# varo:&#xA;git reset --hard &amp;lt;commit-id&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;</description>
			</item>
			<item>
				<title>Peruskomennot arkeen</title>
				<link>https://diary.klj.mywire.org/docs/git-backup/03-peruskomennot/</link>
				<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
				<guid>https://diary.klj.mywire.org/docs/git-backup/03-peruskomennot/</guid>
				<description>&lt;hr&gt;&#xA;&lt;h2 id=&#34;tilanne-ja-historia&#34;&gt;Tilanne ja historia&lt;/h2&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-bash&#34; data-lang=&#34;bash&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;git status&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;git log --oneline --decorate --graph --all&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;Muutosten katselu&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;git diff&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;git diff --staged&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;Lisää ja committaa&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;Lisää yksittäinen tiedosto:&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;git add content/posts/uusi-postaus.md&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;Lisää kaikki:&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;git add .&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;Commit:&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;git commit -m &lt;span style=&#34;color:#4e9a06&#34;&gt;&amp;#34;Lisätty uusi postaus&amp;#34;&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;Pikakommit &lt;span style=&#34;color:#ce5c00;font-weight:bold&#34;&gt;(&lt;/span&gt;vain jo seurattuihin tiedostoihin&lt;span style=&#34;color:#ce5c00;font-weight:bold&#34;&gt;)&lt;/span&gt;:&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;git commit -am &lt;span style=&#34;color:#4e9a06&#34;&gt;&amp;#34;Päivitetty tekstejä&amp;#34;&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;Stash &lt;span style=&#34;color:#ce5c00;font-weight:bold&#34;&gt;(&lt;/span&gt;laita keskeneräinen työ sivuun&lt;span style=&#34;color:#ce5c00;font-weight:bold&#34;&gt;)&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;git stash&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#8f5902;font-style:italic&#34;&gt;# tee jotain muuta, esim. vaihda branchia&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;git stash pop&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;---&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;</description>
			</item>
	</channel>
</rss>
