.. _working-with-github:

Working with Git and GitHub
---------------------------

.. image:: https://octodex.github.com/images/original.png
    :align: right
    :width: 100
    :target: https://github.com


To keep track of your code changes and contribute back to SimPEG, you will
need a Github_ account. Then fork the `SimPEG repository
<https://github.com/simpeg/simpeg>`_ to your local account.
(`How to fork a repo <https://docs.github.com/en/get-started/quickstart/fork-a-repo>`_).


Next, clone your fork to your computer so that you have a local copy. We recommend setting up a
directory in your home directory to put your version-controlled repositories (e.g.  called :code:`git`).
There are two ways you can clone a repository:

1. From a terminal (checkout: https://docs.github.com/en/get-started/quickstart/set-up-git for an tutorial) ::

       git clone https://github.com/YOUR-USERNAME/simpeg

2. Using a desktop client such as SourceTree_ or GitKraken_.

   .. image:: ../../../../images/sourceTreeSimPEG.png
       :align: center
       :width: 400
       :target: https://www.sourcetreeapp.com/

   If this is your first time managing a github_ repository through SourceTree_,
   it is also handy to set up the remote account so it remembers your github_
   user name and password

   .. image:: ../../../../images/sourceTreeRemote.png
       :align: center
       :width: 400

For managing your copy of SimPEG and contributing back to the main
repository, have a look at the article: `A successful git branching model
<https://nvie.com/posts/a-successful-git-branching-model/>`_

.. _Github: https://github.com
.. _SourceTree: https://www.sourcetreeapp.com/
.. _GitKraken: https://www.gitkraken.com/