<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Jonathan Ferreira</title>
    <description>The latest articles on DEV Community by Jonathan Ferreira (@jonathanfsilva).</description>
    <link>https://dev.to/jonathanfsilva</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F814510%2F63543b4b-222b-4413-b56d-03a6f5072dac.jpeg</url>
      <title>DEV Community: Jonathan Ferreira</title>
      <link>https://dev.to/jonathanfsilva</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/jonathanfsilva"/>
    <language>en</language>
    <item>
      <title>Comandos práticos do Git</title>
      <dc:creator>Jonathan Ferreira</dc:creator>
      <pubDate>Mon, 28 Feb 2022 01:08:27 +0000</pubDate>
      <link>https://dev.to/jonathanfsilva/comandos-praticos-do-git-5and</link>
      <guid>https://dev.to/jonathanfsilva/comandos-praticos-do-git-5and</guid>
      <description>&lt;p&gt;O Git é uma ferramenta muito boa, aqui reúno alguns comandos e flags que me ajudam muito no fluxo de trabalho!&lt;/p&gt;




&lt;p&gt;&lt;strong&gt;Corrigir a frase do commit use a flag &lt;code&gt;--amend&lt;/code&gt; para refazer o commit com uma nova mensagem&lt;/strong&gt;&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;`git commit --allow-empty --amend`
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;




&lt;p&gt;&lt;strong&gt;Criar um arquivo de patch para compartilhar alterações em arquivos&lt;/strong&gt;&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git diff &amp;gt; 1.patch
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;




&lt;p&gt;&lt;strong&gt;Mover as alterações feitas no código temporariamente em um stash para mudar ou atualizar a branch&lt;/strong&gt;&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git stash
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;em&gt;Para voltar com as alterações no stash&lt;/em&gt;&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git stash pop
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;




&lt;p&gt;&lt;strong&gt;Criar um gitignore local para não commitar arquivos e pastas e não listá-los no gitignore do repositório&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Primeiro, edite a configuração local do repositório:&lt;/em&gt;&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git config --local --edit
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;em&gt;Depois, adicione a linha abaixo dentro da seção &lt;code&gt;[core]&lt;/code&gt;&lt;/em&gt;&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;excludesfile=.local_gitignore
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Finalmente, crie o arquivo &lt;code&gt;.local_gitignore&lt;/code&gt; e adicione os arquivos/pastas que não quer commitar (inclusive o próprio &lt;code&gt;.local_gitignore&lt;/code&gt;!)&lt;/p&gt;




&lt;p&gt;&lt;strong&gt;Listar uma linha por commit no log&lt;/strong&gt;&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git log --oneline
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;




&lt;p&gt;&lt;strong&gt;Aplicar um ou mais commits de uma branch em outra&lt;/strong&gt;&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git cherry-pick
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;




&lt;p&gt;&lt;strong&gt;Atualizar branchs e informações de:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;todos os remotos&lt;/em&gt;&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git remote update
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;em&gt;remoto atual&lt;/em&gt;&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git fetch
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;em&gt;remoto atual e também atualizar a branch atual&lt;/em&gt;&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git pull
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;




&lt;p&gt;&lt;strong&gt;Colocar um repositório Git dentro de outro (submódulo)&lt;/strong&gt;&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git submodule add &amp;lt;url-do-repo&amp;gt;
git submodule init 
git submodule update
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;




&lt;p&gt;Continuo aprendendo cada vez mais como funciona cada um dos comandos acima conforme a necessidade, abaixo uma lista de referências com mais informações!&lt;/p&gt;




&lt;p&gt;&lt;strong&gt;Referências:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://medium.com/@peter_graham/how-to-create-a-local-gitignore-1b19f083492b"&gt;https://medium.com/@peter_graham/how-to-create-a-local-gitignore-1b19f083492b&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://devconnected.com/how-to-cherry-pick-git-commits/"&gt;https://devconnected.com/how-to-cherry-pick-git-commits/&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.atlassian.com/git/tutorials/saving-changes/git-stash"&gt;https://www.atlassian.com/git/tutorials/saving-changes/git-stash&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://stackoverflow.com/questions/5159185/create-a-git-patch-from-the-uncommitted-changes-in-the-current-working-directory"&gt;https://stackoverflow.com/questions/5159185/create-a-git-patch-from-the-uncommitted-changes-in-the-current-working-directory&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>beginners</category>
      <category>todayilearned</category>
      <category>git</category>
      <category>braziliandevs</category>
    </item>
  </channel>
</rss>
