GIT 101 To change the GitHub account used (email) for pushes: navigate to the repo and view the current email being used git config user.email change it to something else git config user.email "" OR to change the account used for every repo on the computer git config --global user.email To add an existing codebase to an empty online repo navigate to folder that you want to make a git repo of git init git add . git commit press i to insert text, enter a good DESCRIPTIVE commit message, hit ESC, and hit :x when finished git remote add origin git push -u origin --all git push -u origin --tag To create a new online repo from existing code create repository on server navigate to folder where you want to clone repository (if it's the same folder on the server you're storing it in, delete the folder created for you) git clone if you have existing files you need to commit, drag them into that new repository folder now navigate to the repository folder git add . (or whatever files/folders you want to add to the staging area) git commit (press i to insert text, enter a good descriptive commit message, hit ESC, and hit :x when finished) To grab a repo for the first time git clone To fetch latest changes to a repo since the last time you pulled or cloned it git fetch this will not merge into your work, you need to do it manually To both fetch AND merge changes for a repo since the last time you pulled or cloned it: git pull To reset the selected branch to what you just fetched or pulled git fetch --all git reset --hard origin/ To add files to your next commit git add git add / git add . for wildcard statements, use git add *.html (for only files with an .html file extension, and so on) To remove files that you've staged from your next commit git reset to remove all files git reset To commit git commit this opens up the vim editor press i or some other key to start inserting text type your commit message press ESC to stop inserting text :wq to both rewrite and exit the current file OR :x to exit while saving changes to your commit message if you made a mistake and want to abort your commit attempt, use :cq[uit]! which will force an error to VIM and not save any changes BUT IF YOU'RE LEARNING VIM LIKE ME git commit -m "" if you add in -a into the commit command, then you commit changes to files currently tracked by the repo (shortcut for if you don't have any new files to add into the repo) git commit -m "rebuild pages" --allow-empty this is just to reload the GitHub website if something goes wrong to edit a local commit message git commit --amend if you've already pushed the commit to an online branch, you'll need to force push afterwards as well (not recommended since it changes repo history and requires anyone who previously pulled to fix their local history manually) git push --force To delete a file from a repo (make sure to commit afterwards) git rm sample_file.txt To delete a file from a repo but keep it locally (make sure to commit and move the file elsewhere afterwards) git rm --cached sample_file.txt To view commit history git log To push to origin/some other remote git push OR git push -u (if first time) To ignore files create a .gitignore file in root with... touch .gitignore You can then do the same format as 'add' to exclude files/folders/wildcards To exclude files (same as ignore, but these rules do not get commited with the repo) .git/info/exclude and edit that file instead If you need to delete files from a repository git rm git rm -r To change remote git remote -v git remote set-url To create new branch and swap to it git checkout -b OR git branch git checkout To swap branches git checkout To merge branches (make sure you're currently checked out on the destination branch first) git merge For merge conflicts INSTALL A MERGE TOOL TO HELP MAKE YOUR LIFE EASIER Meld is pretty good then use (if you set it as your mergetool during installation) git mergetool To store changes not ready for commit yet git stash then you can swap to another branch when you swap back and want to start working again, use git stash apply drop the stash once you finish with git stash drop This can also be used when pulling a commit with updated files so you don't lose any local changes `pop` combines apply and drop git stash git pull git stash pop resolve any conflicts that may appear afterwards To enforce LF line endings instead of CRLF line ends on Windows git config core.autocrlf false git config core.eol lf both commands can be `--global` if you want to change this for all your repos If Git keeps pushing with the wrong user to a repo, run the following as admin to reset saved git credentials git config --system --unset credential.helper If that doesn't work on Windows, you can try going to Start --> Control Panel ---> User Accounts ---> Manager your credentials ---> Windows Credentials and removing the Git credentials there