Skip to content

Instantly share code, notes, and snippets.

@AugFJTan
Last active September 17, 2017 01:16
Show Gist options
  • Save AugFJTan/c021b2d28ac135a1d800a5538b871b39 to your computer and use it in GitHub Desktop.
Save AugFJTan/c021b2d28ac135a1d800a5538b871b39 to your computer and use it in GitHub Desktop.
RME Programmers 2nd Lesson Overview

1st Lesson Recap

  • Basic concept of Git as a distributed version control system
  • Setting up Git
# You only need to run username and e-mail config once on your computer
git config --global user.name "your-name"
git config --global user.email "[email protected]"
  • Cloning a remote Git repository
git clone https://some-username/name-of-repo.git
  • Adding a reference to remote
git remote add <alias> https://some-username/name-of-repo.git
  • Use of basic Git commands such as
git add -A                    # Cache changes
git commit -m "Some message"  # Save the changes as a commit
git push origin master        # "Push", i.e. upload, changes to a remote repository
git pull origin master        # "Pull", i.e. download, changes from a remote repository

2nd Lesson Outline

Syncing local repo and remote repo

  • origin -> AugFJTan/RME-Programmers
  • upstream -> your-username/RME-Programmers
git remote -v             # View remote info
git pull origin master    # Download changes from repo of origin
git push upstream master  # Push changes to your forked repo

Ignoring files with .gitignore

Ignore unwanted files such as Thumbs.db, *.o, *.exe, etc.

Setting editor configuration with .editorconfig

View code the way you want it: utf-8, tabs=4, etc.

Renaming files

git mv <old-filename> <new-filename>

Delete files with Git

git rm <file>

Creating a new branch and working on it

git checkout -b <new-branch>  # Create new branch
git branch                    # View existing branches

[Commit changes to new-branch]

git push origin <new-branch>           # Push branch to remote repo
git checkout master                    # Return to master branch
git merge <new-branch> master          # merge changes from new-branch onto master
git branch -d <new-branch>             # Delete new-branch locally
git push origin --delete <new-branch>  # Delete new-branch on remote repo

Showing changes

git diff <prev-commit> <more-recent-commit>

Tagging a specific commit as an "important point"

git tag [-a] <tag-name> [-m] ["Some message"]  # For latest commit
git tag <tag-name> <commit>                    # For older commit

Search for stuff using grep

git grep [options]  # Search for stuff based on options

Binary math

  • Hex numbers
  • Bit shifting
  • Binary AND/OR/XOR operations
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment