Git
Basic Workflow
Git clone the repo you are interested in:
git clone https://github.com/jtaubs1/OSCP-Prep.gitNow move into the directory that the reposity or now located in and initialize the repo
git initFor any site that is going to be hosted on GitHub pages, ensure you check out the
gh-pagesbranch
git checkout -b gh-pagesNow 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 statusIf 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.gitNow make the commit official and push to your branch:
git push origin gh-pagesObserving a Repository
List new or modified files not yet commited
git statusShow the changes to files not yet staged
git diff Show the changes to staged files
git diff --cachedShow all staged and unstaged file changes
git diff HEAD Show the changes between two commit ids
git diff <commit1> <commit2>List the change dates and authoris for a file
git blame <file>Show the file changes for a commit id and/or file
git show <commit>:<file>Show full change history
git logShow change history for file/directory including diffs
git log -p [file/directory]Working with Branches
List all local branches
git branchList all branches local and remote
git branch -av Switch to a branch, my_branch, and update working directory
git checkout my_branchCreate a new branch called my_branch
git branch my_branchDelete the branch called my_branch
git branch -d my_branchMerge branch_a into branch_b
git checkout branch_b
git merge branch_aTage the current commit
git tag my_tagMake a Change
Stages the file, ready for commit
git add [file]Stage all changed files, ready for commit
git add .Commit all staged files to versioned history
git commit -m "commit message"Commit all your tracked files to versioned history
git commit -am "commit message"Unstages file, keeping the file changes
git reset [file]Revert everything to the last commit
git reset --hard Synchronize
Get the latest changes from origin (no merge)
git fetchFetch the latest changes from origin and merge
git pullFetch the latest changes from origin and rebase
git pull --rebasePush local changes to the origin
git pushLast updated