2018-11-13 08:54:50 +00:00
|
|
|
---
|
|
|
|
layout: page
|
|
|
|
category-title: Intermediate commands
|
|
|
|
category-page: intermediate
|
2018-11-14 08:56:17 +00:00
|
|
|
tags:
|
2018-11-13 08:54:50 +00:00
|
|
|
author: Andrea Brites Marto
|
|
|
|
title: git
|
|
|
|
---
|
2018-11-14 21:15:38 +00:00
|
|
|
If you want to use <i>Git</i> on the shell you need to know how this command works (usually it is preinstalled on Mac and Linux).<br>
|
2018-11-15 16:19:19 +00:00
|
|
|
The <i>git</i> command providesa set of high-level operations and full access to internals.
|
2018-11-14 21:15:38 +00:00
|
|
|
|
|
|
|
Here is the basic syntax but sometimes you will may have some more complicated:
|
2018-11-15 16:19:19 +00:00
|
|
|
</p>
|
2018-11-14 21:15:38 +00:00
|
|
|
|
|
|
|
<pre>
|
2018-11-15 16:19:19 +00:00
|
|
|
git [flags] [path]
|
2018-11-14 21:15:38 +00:00
|
|
|
</pre>
|
|
|
|
|
|
|
|
First of all, you need to know if you have the right version of git with:
|
|
|
|
|
|
|
|
<pre>
|
2018-11-15 16:19:19 +00:00
|
|
|
git --version
|
2018-11-14 21:15:38 +00:00
|
|
|
</pre>
|
|
|
|
|
|
|
|
Now that we know that we have the right version, we can move to the common <code>git</code> flags used.
|
|
|
|
I will divide commands in different type of operation.<br>
|
|
|
|
|
|
|
|
<h3>Start a working area</h3>
|
|
|
|
<ul>
|
2018-11-15 16:19:19 +00:00
|
|
|
<li>clone: is used to clone a repository in a new directory.</li>
|
|
|
|
<li>init: this onw is used to create an empty Git repository or reinitialize an existing one.</li>
|
2018-11-14 21:15:38 +00:00
|
|
|
</ul>
|
|
|
|
|
|
|
|
<h3>Work on the current changes</h3>
|
|
|
|
<ul>
|
2018-11-15 16:19:19 +00:00
|
|
|
<li>add: add a file contents to the index.</li>
|
|
|
|
<li>mv: move or renamea file, directory or a symlink (a symbolic link).</li>
|
|
|
|
<li>rm: remove files from the working tree and from the index.</li>
|
|
|
|
<li>format-patch id(commit): create a file patch</li>
|
|
|
|
<li>am: apply a patch file</li>
|
2018-11-14 21:15:38 +00:00
|
|
|
</ul>
|
|
|
|
|
|
|
|
<h3>History and state</h3>
|
|
|
|
<ul>
|
2018-11-15 16:19:19 +00:00
|
|
|
<li>log: show commit logs.</li>
|
|
|
|
<li>status: show the working tree status.</li>
|
2018-11-14 21:15:38 +00:00
|
|
|
</ul>
|
|
|
|
|
|
|
|
<h3>Managing modification</h3>
|
|
|
|
<ul>
|
2018-11-15 16:19:19 +00:00
|
|
|
<li>commit: record changes to the repository.</li>
|
|
|
|
<li>diff: show changes between commits.</li>
|
|
|
|
<li>merge: merge two or more development histories together.</li>
|
|
|
|
<li>pull: fetch from and update your local directory with the repository.</li>
|
|
|
|
<li>push: update the remote repository with your changes.</li>
|
2018-11-14 21:15:38 +00:00
|
|
|
</ul>
|
2018-11-15 16:19:19 +00:00
|
|
|
|