git

1git config --global user.email "${email}"
1git config --global user.name "${name}"

Decide on algorithm:

  • If you're scared of insecure hash-sums, go with hash=sha256.
  • If you don't know what a hash sum is, go with hash=sha1.

Init the Git

Start a git in directory ${DIR}:

1git init --object-format=${hash} ${DIR}
2cd ${dir}/

Make a file explaining what the project does, and tell git to track it:

1echo "I hereby solemnly swear never to commit a binary file." > README.md
2git add README.md

Then make the initial commit, explaining the change you just made:

1git commit

Working

Once you make a change to some file, add it and make a commit explaining it.

1git add ${file}
1git commit -m"change ${file}"

Check your history:

1git log

Remotes

If you want to keep a copy on a public site such as Gitlab, so others can see it, then go there and create a blank project (no readme, nothing). Give it the same name as the $DIR directory, above.

Add this as a remote:

1remote=gitlab
2git remote add ${remote}  https://gitlab.com/${username}/${dir}

Tell git you're pushing the branch 'master' to the remote repo 'origin':

1git push -u master origin

Pull down changes that others have made:

1git pull

Branches

A branch is a full copy of the project to test additional ideas. You can make a new branch called 'featurez' like this:

1git branch ${feature_branch}

Have a look at all your branches:

1git branch

Switch to your new branch:

1git checkout ${feature_branch}

And if your changes are rubbish, checkout the "master" branch again, then delete "featurez":

1git branch -D ${feature_branch}

Or if it's a good branch, push it to the remote:

1remote=origin
2git push $remote ${feature_branch}

Merging

Once you like the feature, merge it into the main branch. Switch to master then merge it:

1git merge ${feature_branch}

And delete the branch, as you've already merged it:

1git branch -d ${feature_branch}