Skip to content

Latest commit

 

History

History
105 lines (89 loc) · 4.37 KB

GitHub-Guide.md

File metadata and controls

105 lines (89 loc) · 4.37 KB

GitHub Katas

Position 1: Join the Dojo, Initialize Yatate file

  • Open command prompt
  • Change directory to working folder location
  • git clone /~https://github.com/Trewaters/TheDojo.git
  • Add a text “.txt” file with your name and information
    • Or update your current text “.txt” file with a date and note
  • git add <FILENAME> - stages file, now ready for commit
  • git commit -m “COMMIT_MESSAGE”
  • git push origin master - upload your file
    • Or git remote add origin /~https://github.com/Trewaters/TheDojo.git - use this if you haven’t cloned the repository
  • git log

Position 2: Update your Yatate file

  • Open command prompt
  • Change directory to working folder location
  • git status
  • git pull origin master - pull down any new changes to local repository, before attempting to update your local files
  • git diff HEAD - Check your working tree with git diff
  • Update your Yatate file
  • git add <FILENAME>
  • git diff --staged - see changes that were staged
    • git reset <FILENAME> - if you need to unstage a file
    • git checkout --<TARGET_FILENAME> - if you need to get rid of all the changes since the last commit for
  • git commit -m “COMMIT_MESSAGE”
  • git push - push all the changes to remote repository.

Position 3: Create a Pull Request

Position 4: Create/Merge a Branch to the Master

Position 5: Commit Message

  • git add -a
    • add all previously tracked files, does not capture any new files
  • git commit -m "<MESSAGE_TEXT>"
  • commit rules
    1. Separate subject form body with a blank line (not easy)
      • use 2 message flags. The first will be interpreted as the Subject, then the other will be the content
      • example `git commit -m "<SUBJECT_LINE>" -m "<CONTENT_TEXT>"
    2. Limit the subject line to 50 characters
    3. Capitalize the Subject line
    4. Do not end the subject line with a period
    5. Use the imperative mood in the subject line
    6. Wrap the body at 72 characters
    7. Use the body to explain what and why vs. how

Position 6: Keep the Fork up-to-date

  • Add 'upstream' repo to list of remotes
    • git remote add upstream /~https://github.com/UPSTREAM-USER/ORIGINAL-PROJECT.git
  • Verify the new remote named 'upstream'
    • git remote -v
  • When you need to update your fork, you first fetch the upstream branches and commits into your repo. Checkout your master branch and merge upstream
    • Fetch from upstream remote
      • git fetch upstream
    • View all branches, including those from upstream
      • git branch -va
  • Checkout your master and merge the upstream repo master
    • git checkout master
    • git merge upstream/master
  • Create a branch
    • git checkout master
    • git branch newfeature
    • git checkout newfeature

Position 7: Remove current commit history

  1. git checkout --orphan temp_branch
  2. git add -A
  3. git commit -am "INITIALIZE"
  4. git branch -D master
  5. git branch -m master
  6. git push -f origin master

Position 8: Move commit to a new branch

Position 9: Create a GitHub Repo starting with local files

  • Create a new repository on GitHub.
  • Initialize local directory as a Git repository.
  • Copy GitHub repository's URL
  • git remote add origin <REMOTE_REPOSITORY_URL>
  • git remote -v to verify
  • git push origin master