Git GitLab repos, GUI, issue trackers, workflows, wikis, milestones, kanban, API, ... tutorial guide book parable dangit missing clone, pull, status, add, commit, push, merge, branch, fork, pull request, ... download GUIs Bash commands scripting keys ssh-keygen -t rsa -f keyname -C "user@emailaddress" Mac Homebrew Windows Windows Subsystem for Linux Cygwin Git Bash Linux Debian Ubuntu Xubuntu Chromebook Raspberry Pi scripts Android Termux iOS iSH distributed version control system maintains version history merges changes between and within files peer-to-peer development remote server file system management mistakes you may make key path, permissions chmod go-rwx ~/.ssh/key_name server port, key ~/.ssh/config network connection blocking non-standard ports check what you're going to commit before doing it git status pull and merge before pushing refresh browser after editing page wait for server runner to finish use relative rather than absolute links to files avoid spaces and non-ASCII characters in paths, they need to be escaped https://developer.mozilla.org/en-US/docs/Glossary/Percent-encoding don't use special characters in file names (Windows doesn't allow colons, Linux doesn't allow ampersand, ...) distinguish upper vs lower-case all content in repo (except for files that are too large to compress) archive size O(MBs)/person/week check size before commit du ncdu compress, resize pictures for Web ImageMagick, GIMP JPG: compressed, PNG: uncompressed compress, encode vidoes for Web ffmpeg files ~/.gitconfig [user] name = your name email = you@email (lots of other options) ~/.ssh/config host config_name hostname machine_name user user_name port port_number identityfile ~/.ssh/key_name .gitignore, .git/info/exclude untracked files/directories to ignore .git/hooks/post-merge script to run after a merge (which happens after a pull) .git/hooks/post-receive script to run after receiving a push commands git help get help git config --list list config git config --system system config git config --global user config git config --global user.name "Firstname Lastname" set name for commits git config --global user.email "address@site" set email for commits git config --global push.default simple default push only the current branch git config --global fetch.prune true locally prune branches that are remotely deleted git config --global core.editor vim set the editor git config --global merge.tool meld set the merge tool to meld git config --global pull.rebase true rebase rather commit automatic merges git config --global receive.denyCurrentBranch updateInstead update remote after push git config --global core.sharedRepository 0640 default access group read git config --global core.autocrlf true configure Windows to use Linux/OSX line endings git init initialize a repository git init --bare initialize a bare repository git clone path_to_repo clone a repository mounted in the file system git clone user_name@machine_name:repo_name clone a repository with a SSH login git clone config_name:repo_name clone a repository with a SSH name config in ~/.ssh/config git remote -v list remotes git remote set-url origin URL set the origin remote git remote add name URL add a remote git pull fetch and merge changes git push push changes git push -u origin branch_name push a branch to origin git push --mirror mirror a repo git status report the repository status git add . stage all changed files to commit git commit -m "commit message" commit changes git commit -a -m "commit message" stage and commit changes git log show history git reflog show reference updates git log --name-status show names and status of changed files git log --graph --oneline --stat compact history view with graph and changes git rm remove a tracked file git mv move a tracked file git revert undo a commit git clean -f remove untracked files git reset --hard undo uncommitted changes git reset --hard origin/master reset to match remote git reset HEAD@{index} reset back to index git checkout -b branch_name create new branch git checkout branch_name checkout branch git push -u origin branch_name push new branch git merge branch_name merge branch git merge --squash branch_name merge branch, squashing its commits git mergetool -t meld resolve a conflicted merge with the meld GUI git checkout --ours . checkout existing files during merge conflict git checkout --theirs . chekout new files during merge conflict git branch -a list branches git branch -d branch_name delete local branch git push origin --delete branch_name delete remote branch git fetch -p locally prune deleted remote references git tag assign a tag to a commit git blame show revisions of file lines git diff show changes between commits git diff commit1 commit2 show changes between commits git diff branch1 branch2 show changes between branches git submodule add path_to_repository nest a repository git clone --recursive close a repo including submodules git submodule update --init initialize and update submodules git submodule update update submodules git submodule update --remote update submodules to remote git subtree add -P path_in_repo remote_repo master --squash add a remote repo as a subtree git subtree pull -P path_in_repo remote_repo master --squash pull from a remote repo into a subtree git archive --format=tar --remote=repo_path HEAD | (tar xf -) copy the working tree of a repo git lfs track file extension for versioning large files find . -type d -name ".git" -exec bash -c "cd {}/..; echo ''; pwd; echo ''; git add .; git status; git commit -a -m 'find git'; git pull; git push;" \; recursively update all repos under a directory aliases alias ga="git add ." alias gap='git add .;git commit -a -m "wip";git push' alias gb='git branch -a' alias gbcreate='git checkout -b' alias gbdelete='git branch -d' alias gbpush='git push -u origin' alias gbpushdelete='git push origin --delete' alias gc="git commit -a -m" alias gcw="git commit -a -m 'wip'" alias gd="git diff" alias gf='git pull' alias gk='git checkout' alias gko='git checkout --ours' alias gkt='git checkout --theirs' alias gl="git log --name-status --graph" alias gm='git merge' alias gms='git merge --squash' alias gp='git commit -a -m "wip";git push;git status' alias gr='git reset --hard; git clean -f' alias gs='git status' alias gt='git push'