{"id":117,"date":"2017-04-13T10:54:00","date_gmt":"2017-04-13T13:54:00","guid":{"rendered":"https:\/\/www.linuxpro.com.br\/2017\/04\/git-simples-e-rapido\/"},"modified":"2026-09-08T01:56:22","modified_gmt":"2026-09-08T04:56:22","slug":"git-simples-e-rapido","status":"publish","type":"post","link":"https:\/\/www.linuxpro.com.br\/en\/2017\/04\/git-simples-e-rapido\/","title":{"rendered":"Git made simple and fast"},"content":{"rendered":"<p><img loading=\"lazy\" decoding=\"async\" alt=\"Mascote do LinuxPro diante de um quadro com o diagrama de branch e merge do Git, ao lado do losango do projeto\" src=\"\/wp-content\/uploads\/2026\/09\/git-v5.webp\" width=\"1052\" height=\"652\" \/><\/p>\n<div style=\"background:#fff8e1;border-left:4px solid #8b1a1a;padding:.8em 1em;margin:1em 0\"><strong>Note (2026):<\/strong> the workflow below remains the everyday routine. The package is now <code data-no-translation=\"\">git<\/code> (not <code data-no-translation=\"\">git-core<\/code>), the default branch is usually <code data-no-translation=\"\">main<\/code> and the modern SSH key is Ed25519. The history \u2014 BitKeeper, the ten days of 2005, Junio Hamano, Git 2.55 \u2014 is in <a href=\"\/en\/2026\/09\/a-historia-do-git\/\">The history of Git<\/a>.<\/div>\n<p>A short cheatsheet: install, configure, clone, commit, push. No object theory. If you've never used Git, these commands handle 90% of cases.<\/p>\n<p><!-- more --><\/p>\n<h2>Install<\/h2>\n<p>Debian\/Ubuntu and derivatives:<\/p>\n<pre data-no-translation=\"\"><code class=\"language-bash\" data-no-translation=\"\">sudo apt update\nsudo apt install git\ngit --version<\/code><\/pre>\n<p>In 2026 the package is <code data-no-translation=\"\">git<\/code>. The old name <code data-no-translation=\"\">git-core<\/code> was a metapackage; don't look for it.<\/p>\n<h2>Name, email and default branch<\/h2>\n<pre data-no-translation=\"\"><code class=\"language-bash\" data-no-translation=\"\">git config --global user.name \"Seu Nome\"\ngit config --global user.email seu@email.com\ngit config --global init.defaultBranch main\ngit config --global pull.rebase false<\/code><\/pre>\n<p><code data-no-translation=\"\">user.name<\/code> and <code data-no-translation=\"\">user.email<\/code> go into every commit. Without them Git complains. The industry's default branch stopped being <code data-no-translation=\"\">master<\/code> around 2020; <code data-no-translation=\"\">main<\/code> is what GitHub, GitLab and Git itself use for a new repository.<\/p>\n<h2>SSH key<\/h2>\n<p>Ed25519, not RSA 4096 \u2014 smaller and the current default. Details of the passwordless workflow: <a href=\"\/en\/2017\/04\/ssh-sem-senha\/\">Passwordless SSH<\/a>.<\/p>\n<pre data-no-translation=\"\"><code class=\"language-bash\" data-no-translation=\"\">ssh-keygen -t ed25519 -C \"seu@email.com\"\neval \"$(ssh-agent -s)\"\nssh-add ~\/.ssh\/id_ed25519\ncat ~\/.ssh\/id_ed25519.pub<\/code><\/pre>\n<p>Paste the public key into GitHub\/GitLab \u2192 Settings \u2192 SSH keys. Test:<\/p>\n<pre data-no-translation=\"\"><code class=\"language-bash\" data-no-translation=\"\">ssh -T git@github.com<\/code><\/pre>\n<h2>New repository or clone<\/h2>\n<pre data-no-translation=\"\"><code class=\"language-bash\" data-no-translation=\"\">mkdir projeto && cd projeto\ngit init\n# ou, o caso comum:\ngit clone git@github.com:usuario\/projeto.git\ncd projeto<\/code><\/pre>\n<h2>Add, commit, status<\/h2>\n<pre data-no-translation=\"\"><code class=\"language-bash\" data-no-translation=\"\">git status\ngit add arquivo.txt          # ou: git add -A\ngit commit -m \"mensagem curta no imperativo\"\ngit log --oneline -5<\/code><\/pre>\n<p class=\"translation-block\">The commit stays in the <em>local<\/em> repository. It isn't on GitHub yet.<\/p>\n<h2>Branch: switch, not just checkout<\/h2>\n<pre data-no-translation=\"\"><code class=\"language-bash\" data-no-translation=\"\">git switch -c feature\/login    # cria e entra\ngit switch main                # volta\ngit merge feature\/login\ngit branch -d feature\/login<\/code><\/pre>\n<p><code data-no-translation=\"\">git switch<\/code> and <code data-no-translation=\"\">git restore<\/code> (undo file changes) have existed since Git 2.23 (2019) and separate the tasks that <code data-no-translation=\"\">checkout<\/code> used to combine. <code data-no-translation=\"\">checkout<\/code> still works; for new code, use the two new commands.<\/p>\n<pre data-no-translation=\"\"><code class=\"language-bash\" data-no-translation=\"\">git restore arquivo.txt           # descarta mudan\u00e7a no working tree\ngit restore --staged arquivo.txt  # tira do index, mant\u00e9m o arquivo<\/code><\/pre>\n<h2>Remote and push<\/h2>\n<pre data-no-translation=\"\"><code class=\"language-bash\" data-no-translation=\"\">git remote add origin git@github.com:usuario\/projeto.git\ngit push -u origin main<\/code><\/pre>\n<p>Next time: <code data-no-translation=\"\">git push<\/code> and <code data-no-translation=\"\">git pull<\/code>. The <code data-no-translation=\"\">-u<\/code> records the upstream. If the remote still uses <code data-no-translation=\"\">master<\/code>, change the branch name \u2014 don't invent <code data-no-translation=\"\">main<\/code> on a remote that doesn't have it.<\/p>\n<pre data-no-translation=\"\"><code class=\"language-bash\" data-no-translation=\"\">git branch -M main    # s\u00f3 se voc\u00ea est\u00e1 migrando um repo antigo<\/code><\/pre>\n<h2>A day's workflow<\/h2>\n<pre data-no-translation=\"\"><code class=\"language-bash\" data-no-translation=\"\">git pull\ngit switch -c fix\/typo\n# edita\ngit add -A\ngit commit -m \"Corrige typo no README\"\ngit push -u origin fix\/typo\n# abre o pull request no GitHub\/GitLab\ngit switch main<\/code><\/pre>\n<h2>Video: Git Made Simple (LinuxTips)<\/h2>\n<p class=\"translation-block\">Jeferson Fernando's <a href=\"https:\/\/www.youtube.com\/channel\/UCJnKVGmXRXrH49Tvrx5X0Sw\">LinuxTips<\/a> recorded \u201cDescomplicando o GIT\u201d \u2014 still the best Portuguese-language walkthrough of the workflow. The history (BitKeeper, the ten days, Git 2.55) is in the new post.<\/p>\n<div style=\"position:relative;padding-bottom:56.25%;height:0;overflow:hidden;margin:1.5em 0\">\n<iframe src=\"https:\/\/www.youtube.com\/embed\/_aj3hsEh9iw\" title=\"Descomplicando o GIT \u2014 LinuxTips\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share\" allowfullscreen style=\"position:absolute;top:0;left:0;width:100%;height:100%;border:0\"><\/iframe>\n<\/div>\n<h2>More<\/h2>\n<ul>\n<li><a href=\"\/en\/2026\/09\/a-historia-do-git\/\">The history of Git<\/a> \u2014 BitKeeper, Linus, Junio, 2.55<\/li>\n<li><a href=\"\/en\/2026\/09\/a-historia-de-linus-torvalds\/\">The history of Linus Torvalds<\/a><\/li>\n<li><a href=\"https:\/\/git-scm.com\/book\/pt-br\/v2\">Pro Git (official book, v2 in Portuguese)<\/a><\/li>\n<li><a href=\"https:\/\/www.youtube.com\/watch?v=sCr_gb8rdEI\">Two decades of Git \u2014 interview with Linus (2025)<\/a><\/li>\n<\/ul>","protected":false},"excerpt":{"rendered":"<p>A short cheatsheet: install, configure, clone, commit, push. No object theory. If you have never used Git, these commands cover 90% of cases. Install on Debian\/Ubuntu and derivatives: sudo apt update sudo apt install git git \u2013version In 2026 \u2026 <a title=\"Git made simple and fast\" class=\"read-more\" href=\"https:\/\/www.linuxpro.com.br\/en\/2017\/04\/git-simples-e-rapido\/\" aria-label=\"Read more about Git simples e r\u00e1pido\">Read more<\/a><\/p>","protected":false},"author":0,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[45,46,2],"tags":[50,47,48,49,4,51],"class_list":["post-117","post","type-post","status-publish","format-standard","hentry","category-desenv","category-devops","category-linux","tag-desenv","tag-devops","tag-git","tag-github","tag-linux","tag-win"],"_links":{"self":[{"href":"https:\/\/www.linuxpro.com.br\/en\/wp-json\/wp\/v2\/posts\/117","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.linuxpro.com.br\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.linuxpro.com.br\/en\/wp-json\/wp\/v2\/types\/post"}],"replies":[{"embeddable":true,"href":"https:\/\/www.linuxpro.com.br\/en\/wp-json\/wp\/v2\/comments?post=117"}],"version-history":[{"count":8,"href":"https:\/\/www.linuxpro.com.br\/en\/wp-json\/wp\/v2\/posts\/117\/revisions"}],"predecessor-version":[{"id":1061,"href":"https:\/\/www.linuxpro.com.br\/en\/wp-json\/wp\/v2\/posts\/117\/revisions\/1061"}],"wp:attachment":[{"href":"https:\/\/www.linuxpro.com.br\/en\/wp-json\/wp\/v2\/media?parent=117"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.linuxpro.com.br\/en\/wp-json\/wp\/v2\/categories?post=117"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.linuxpro.com.br\/en\/wp-json\/wp\/v2\/tags?post=117"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}