Very basic commands to use Git

Very basic commands to use for Git
in a repo hosted on a git-manager platform
-no, seriously, that's veeery basic and more of a self-reminder than a guide...

Basically because I've grown tired of looking around the whole web, to remember the correct procedure, every time I get my hands back into using git again after months or years that made me either forget or too insecure to go blindly (and make a mess with the little I've done so far).

Using the CLI (Command Line Interface) is better for me, as actions are limited on web-interfaces and otherwise it may be required to also install a GUI (Graphical User Interface) git-manager usually optimised for the repo's hosting platform.
So first, set Git on the machine meant to use it, following this link which I think might be the simpliest step-by-step procedure to install, set account and then set the repo (Codeberg is the current example). A somewhat more complete documentation, with further resources in case of specific use-cases, can be found on the Git community website.
I've also found this tip on the Codeberg documentation (and specific for hosting there I guess) to avoid linking (therefore exposing when sending commits) your actual email address while configuring git, in the case just like me you're just having fun trying out the repo working locally and you don't really need to be reachable for collabs (but remember to reconfig if you'll do!).

If you don't want to include your email address with your commits, you can opt to specify USERNAME@noreply.codeberg.org here instead, where USERNAME is your Codeberg username.

Another tip before proceeding: if you're coming back at modifying a repo you've already set up, and if (and when) at any point you won't remember if the local copy is synchronised with the remote one, run these two commands: the first to check the synchronisation status and the second, if you discover through the check that the remote repository was updated, in order to populate your local folder with the latest changes from it.

After this, just enter the local folder you've copied/synchronised the repo with and modify or add files and directories locally as you like, with your preferred text/code editors.
Afterwards, to send the changes made locally to the remote repository, run the following git commands:

As a good practice you should NEVER run code you don't know the effects of in your terminal, so I should add below what each command does, both to remember and be sure what's needed each time or not:

  1. git add . is needed for git to start tracking ("add") the changes made to a set of files (the "." stands for "all files from the root folder recursively") so that they can be staged for commit
  2. git commit -m "whatever message like: updating the repo" is needed to confirm these changes (you "commit" them) and keep record of the batch of edits made, so it requires a comment, so the -m option stands for a "message" you have to write between single or double quotation marks
  3. git push this last step is to synchronize ("push") the commit from the local repository to the remote one. If you are using HTTPS, you will be asked for your Codeberg username and password. If you want to avoid entering your password every time, consider using SSH instead.

Extra tips and tests

You could also avoid the first command by adding the -a option which automatically stages modified and deleted files for commits -but that's just one less step to make mistakes on or to prevent them...
Anyway the command would be: git commit -am "here the commit message"

Also remember that each line is a different command, each must be run separately, so you can't just copy/paste the whole block but one at a time.
Unless, if I'm not wrong, using a "pipe" | symbol between each command on a single line -this should concatenate them one after the other.

So let's try like this:

            
git add . | git commit -m "updating the repo" | git push
            
        

...and no: it results in a fatal error as processes by git seem to run over each other like this.

Nonetheless, assuming a similar use of the Linux terminal, I successfully manage to concatenate the commands with the && instead of the |.
Just like this:

            
git add . && git commit -m "updating the repo" && git push
            
        

Once again the suggestion to not run stuff you don't know standed true, as I should have looked for meaning and uses of the two symbols (HERE I SHOULD LINK THEM), although I was ultimately lucky as git prevented the fatal error to break stuff.
So here is it: a blogpost of a person who was privileged enough to fail safely made for someone else (or a future me) to learn before this error!