#notes #documentation ### Create a git repository `git init` - This defines the folder as a git repository, and creates `.git`, a folder that contains metadata about the repo, like where the *remote* (repository hosted somewhere else) is, and other useful stuff like version control. You should not need to directly interact with this folder. `git add .` - This makes all files and folders in the current repository(can also be more precise by replacing `.` with specific files) tracked. `git commit -am "The Epoch"` - Syntax breakdown: - `-a` All, commit all changes - `-m` Have a message, takes a string argument, in this example, "The Epoch" #### If adding a remote repository, GitHub or otherwise. `git remote add origin https://urltorepo.com/path/to/repo` - Telling git that the files should come from and go to that remote repository, where `https://urltorepo.com/path/to/repo` is the destination repo. - If the url is wrong, it can be removed with `git remote remove origin` `git branch -M main` - Syntax breakdown: - `-M`, shortcut for `--move --force`, used to move/rename a branch. - Telling git that we want the current branch to be `main`. `git push -u origin main` - Synatx breakdown: - `-u` is a shortcut for `--set-upstream` - Telling git that we want the main host of the repository(`origin`, or `https://urltorepo.com/path/to/repo`) to be the host. After this is run one time, git remembers, and you can shorten it to `git push`, to take commits(saved changes) from your local code, and send them to remote(GitHub or other Git server). ### Update code on github/remote `git commit -am "changes"` - Tell git to keep track of all the changes you made `git push` - Take code here and put it on the server ### Get code from github `git clone https://remotehost.com/repo/to/clone` - Download a folder containing all of the code and versions to a project, where `https://remotehost.com/repo/to/clone` is the url of the repo in question. ### Fetch recent changes from github `git pull`