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.
-
open the GitBash (Windows) or the terminal (Mac).
-
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! -
with
git status
I query the current status. (Blue) I see that I have "Untracked files " and it even suggests adding them withgit add
. -
i add the file
HowToGitClone.md
withgit 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
withgit add
. -
I then query the status again and see that all files have now been added.
-
-
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.
-
-
git push
now ensures that our changes are uploaded. (gray)