Skip to main content

How to - git add, commit & push

Ok, you have created or previously cloned a repository, have now changed something and want to "upload" it. We call this pushing!

Let's take a look at an example

I have just created a Git clone tutorial and now want to upload it to our repository.

Screenshot 1

Screenshot 2

  1. open the GitBash (Windows) or the terminal (Mac).

  2. with cd I navigate to the folder of the repository. (Green)

    e.g.: cd Git_Stuff\guides
    Git_Stuff\guides *is the name of the path. Your path is probably different!

  3. with git status I query the current status. (Blue) I see that I have "Untracked files " and it even suggests adding them with git add.

  4. i add the file HowToGitClone.md with git add. (Yellow) Then I query the status again, but this is not necessary but only for demonstration purposes!

    • The HowToGitClone.md is displayed under "Changes to be committed ".

    • Next, I add the folder Screenshots-GitClone with git add.

    • I then query the status again and see that all files have now been added.

  5. git commit -m "..." (Red)

    • Each commit is provided with a message. Especially when several people are working together, it can be useful to briefly describe what has been changed. In my case, I have added instructions for cloning repositories.

    • The -m stands for message, by the way.

    • I then ran git staus again for demonstration purposes. We can now see that all local changes have been added to the local repository and provided with a message.

  6. git push now ensures that our changes are uploaded. (gray)