Skip to content

Conversation

karanphil
Copy link
Contributor

@karanphil karanphil commented Jan 28, 2025

Here is a new Git page, which is a fusion of both previous pages about Git. It is mostly the one previously found in the good practice section, but I salvaged some parts of the other Git page. Also removed the good practice section.

I would encourage building the html for this review. It wont be easy directly on Github.

@karanphil karanphil changed the title New Git pae New Git page Jan 28, 2025
@zinelya zinelya self-requested a review January 28, 2025 21:12
:align: right

.. code-block:: bash
Let's say you want to develop Scilpy. Instead of cloning Scilpy directly on your computer, you should **fork** it, i.e. copy it as one of your own repositories in your own account. On Github, you can find the button *fork* on the top right of Scilpy's repository page. Then, you can clone this copy of the repository on your computer (find the link by clicking on Github's green button *Code*): :bash:`git clone INSERT_LINK_TO_YOUR_FORKED_REPOSITORY`
Copy link
Contributor

@zinelya zinelya Jan 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we can have an image of the UI showing the fork button and also how the forked repo looks like to clone it:

image
image

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oui bonne idée!

@zinelya zinelya requested a review from CHrlS98 January 29, 2025 23:23
Copy link
Contributor

@CHrlS98 CHrlS98 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

5 months later, never too late!

# Delete a branch:
git branch -d my_branch # For a local branch
git push origin --delete my_branch # For a branch on origin
When working in a branch other than the main one (*master* or *main*), you should often save (update) your modifications online. Each update is called a **commit**. First, to see which files have been modified without telling Git, use :bash:`git status`. Then, to add or update a file in Git's memory, use :bash:`git add my_file`. You can also add all files that have been modified and that Git already knew about, with :bash:`git add -u`. If you check again with :bash:`git status`, everything in green will be recorded with the next command: :bash:`git commit -m "Message to explain the work I have been doing in this update"`. To send these changes to the same branch name in your forked repository, use :bash:`git push origin my_branch`.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we explain that a commit is not automatically backed up online, it is only a checkpoint made locally until it is pushed.

Comment on lines -155 to +126
git push origin my_branch # Will automatically send it to the same branch name in your forked repo.
In Git, your working directory is the local folder containing the current state of your project files. As you make changes to these files, they are tracked by Git but not yet committed (see :bash:`git status`).

# From your forked repo to the upstream repo:
# Use the Pull Request button on internet
The staging area, also known as the index, is an intermediate space where you can organize and prepare the changes you want to include in your next commit (see :bash:`git add`). By adding changes to the staging area, you're essentially telling Git which changes should be recorded in the upcoming commit (see :bash:`git commit`). Your local repository is the hidden .git folder within your working directory, where Git stores the entire version history, including all commits and branches. It is separate from the working directory, ensuring that your project's history is preserved even if you make changes or delete files in your working directory.

# From your local repo to the upstream repo:
# DON'T DO THAT. Didn't you see that there is no such arrow on Figure 1!
A remote repository is a version of your project stored on a remote server, allowing for collaboration with other developers. You can push your local commits (see :bash:`git push`) to the remote repository and pull changes made by others (see :bash:`git pull` or :bash:`git fetch`), keeping your project in sync across multiple environments.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel like this should be said earlier, maybe it would fit where commits and pushes are explained.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants