# Git The stupid content tracker. No more need for V1, V2, V2 Final or V2 Final Final edit by Malik Final This terminal-based program is a lightweight version control, that is highly useful for dealing with code/text activities. This does not require a remote origin, a local repo will be fine with the use of the Baja Cloud, just upload any .git files with it. This will track everything in the specified git directory (files, child directories, etc.) ## Common Commands ### Note Need to be in a git repo directory to use git commands. ```bash # change directory cd # Go to the parent directory cd. # initialize a git repository (local only) git init # add (stage) all changes (in files) git add -A # Commit staged changes with a message git commit -m "commit message" # create a new branch and check into it git checkout -b # change the current branch to an existing branch git checkout # delete a branch git branch -D # set upstream (default remote branch) for a local branch # (upload) git push -u origin # pull the latest changes from the remote repository # (download) git pull origin # revert a commit git revert # see commit logs (multi-line includes the date, who and other useless info) # Is much longer git log # see logs in one line (with commit hash) # shorter git log --oneline # see the list of both local and remote branches git branch -a # see the list of local branches git branch # see the status of the current local repository # see what files/changes are uncommitted git status # rebase a branch with another one git rebase # see remote repositories linked to the current local repository git remote -v # add a new origin (remote repository) git remote add origin # cache GitHub credentials git config --global credential.helper 'cache --timeout=36000' # remove git cache git rm -r --cached. # config username and email for a git project git config user.name "username" git config user.email "email" ```

Git cheat sheet

The commands discussed above–and more–are summarized in this cheat sheet available to download.

### Type Must be one of the following: - **init**: A special case only for the very first commit (example: init(location)) - **build**: Changes that affect the build system or external dependencies (example scopes: gulp, broccoli, npm) - **ci**: Changes to our CI configuration files and scripts (example scopes: Travis, Circle, BrowserStack, SauceLabs) - **docs**: Documentation only changes - **feat**: A new feature - **fix**: A bug fix - **perf**: A code change that improves performance - **refactor**: A code change that neither fixes a bug nor adds a feature - **style**: Changes that do not affect the meaning of the code (white space, formatting, missing semi-colons, etc) - **test**: Adding missing tests or correcting existing tests - **chore**: - **added**: Added content but not a complete feature - **removed**: Removed files or content only - **merged**: Used when a branch's content is merged into another branch ### Message The subject contains a succinct description of the change (this will show up in the logs): - use the imperative, present tense: "change" not "changed" nor "changes" - don't capitalize the first letter - no dot (.) at the end ### Example Commit ```bash git add -A # adds all of the files/changed files to the commit stage (pre-commit) ``` ```bash git commit -m"feat(DAQ)^: optimized algorithm" # the message that will show up in the logs ``` Another Example ```bash git commit -m"Feat (API)^: send an email to the customer when a product is shipped" ``` ### How to Commit ``` "(scope or file that has been changed): short description" ``` Replace with just the type ^ for any breaking commits