I often forget to start at the beginning so this is to remedy that, at least for git.

Requirements

  • git

Initialise or clone

To start using git, you will need to either initialise git, if you already have code or clone if you do not.

Clone

git clone {repo.url}

Init

Change to the code folder and run:

git init
git remote add origin {some.url}
git add .
git commit -m "Initial Commit"

Status

To get an overview of your repo and saved/unsaved files

git status

Working with your Code

Whenever you feel you want to save your code, check your git status, and selectively add files that make up a single commit.

For example:

git add src/todo.lst
git add main.js
git commit -m "My Todo List"

Everytime you commit, a reference to your files are saved and stored. However it’s still just local. When you are ready to send to the git server do:

git push

You may get a warning that git was unable to push, the usual reason being that there are changes on the server that you don’t have, so do:

git pull

For simple differences, git will automatically resolve. More complicated differences will have to be resolved manually with git merge

.gitignore

The .gitignore file is very important if you’re working on a public repo, it prevents git from uploading files and folders you don’t want to be commited. If you have private keys or scripts you don’t want uploaded this can be a lifesaver.

To start with, you should problably block a build folder:

build/**
.vscode

The above will prevent any files in the build folder being uploaded and prevent the Visual Code settings also.