Use git init [name of repo]
to initialize a git repository
git add [filename]
It is possible to pass directories as args. No args adds everything.
Stores the changes of one or more files.
Contents:
- Message
- Author
- Unique reference SHA-1
- Parent reference
- Date
- File diffs
git commit -m message
Git is a distributed version control system, so you can use it offine and locally. But it is really useful to share our work with others.
You can add a remote repo, in this case hosted by Github.
git remote add origin
git remote --verbose
to check the remote has been added. It lists a fetch and
push remote, it is normally the same.
If you have a single remote, it is called origin.
Send commits in a local repo to a remote. Made through HTTP or SSH protocols. Only differences are sent.
git push --set-upstream origin master
The first time. Also
git push -u origin master
It is a healthy option to make sure the local
master
branch tracks the origin remote’s branch master.
A tracking branch is the default push or fetch location for a branch
The next time you can run:
git push origin master
- Clone
- Create a new local repo from an existing remote. It’s a complete copy including all metadata
git clone [remote location]
git fetch
to download the new commits but skip the merge step, in contrast togit pull
Push or fetch: It’s recommended git fetch
. You can fetch regularly in the
background and only include changes in the branch when it’s convenient and
using the most convenient method.
- command –help