githubEdit

Git

Basic Workflow

  • Git clone the repo you are interested in:

git clone https://github.com/jtaubs1/OSCP-Prep.git
  • Now move into the directory that the reposity or now located in and initialize the repo

git init
  • For any site that is going to be hosted on GitHub pages, ensure you check out the gh-pages branch

git checkout -b gh-pages
  • Now make all the chages you want to make on the repo.

  • To see the status of the files changed before pushing the new commits.

git status
  • If these are the changes you want to make:

git add .
  • Now commit the changes locally

git commit -m "initial commit"
  • You only have to do the below command once, but this will instruct git where to push the changes to:

git remote add origin https://github.com/jtaubs1/jtaubs1.github.io.git
  • Now make the commit official and push to your branch:

git push origin gh-pages

Observing a Repository

  • List new or modified files not yet commited

  • Show the changes to files not yet staged

  • Show the changes to staged files

  • Show all staged and unstaged file changes

  • Show the changes between two commit ids

  • List the change dates and authoris for a file

  • Show the file changes for a commit id and/or file

  • Show full change history

  • Show change history for file/directory including diffs

Working with Branches

  • List all local branches

  • List all branches local and remote

  • Switch to a branch, my_branch, and update working directory

  • Create a new branch called my_branch

  • Delete the branch called my_branch

  • Merge branch_a into branch_b

  • Tage the current commit

Make a Change

  • Stages the file, ready for commit

  • Stage all changed files, ready for commit

  • Commit all staged files to versioned history

  • Commit all your tracked files to versioned history

  • Unstages file, keeping the file changes

  • Revert everything to the last commit

Synchronize

  • Get the latest changes from origin (no merge)

  • Fetch the latest changes from origin and merge

  • Fetch the latest changes from origin and rebase

  • Push local changes to the origin

Last updated