Navigate to repository directory.
Open Directory
cd c:/sites/my-repository
List Directories.
dir
Clone Repository
git clone https://github.com/brandonbrule/my-repository.git
Commiting Files and Changes.
Git pull most recent changes
git pull
Add new files or changes
git add -A
Commit with message
git commit -m "this is my commit message"
Push changes and files to repo
git push
git branches.
Pull most recent changes
git pull
Create new branch
git branch name_of_branch
Push branch to repository
git push origin name_of_branch
Switch to branch - Checkout branch
git checkout name_of_branch
List Repository Branches
git branch
Committing to branch
Make sure you're in your branch
git checkout name_of_branch
Pull most recent copy
git pull
Add files and changes
git add -A
Commit files, changes and message
git commit -m "my message to myself and others"
Push the files to the repository branch
git push --set-upstream origin name_of_branch
Switching branches
git checkout name_of_branch
git pull
Merging Branches
Checkout Branch - In this case we're merging back to master
git checkout master
git pull
Merging the branch
git merge name_of_branch
Push the merge
git push origin master
Revert to commit including all files
Checkout branch to revert
git checkout name_of_branch
Reset to revision number
git reset --hard commit#
Clean up the files
git clean -fd
Add the reverted setup
git add -A
Commiting the reverted setup
git commit -m "reverting back all files to this"
Force add might be needed
git push origin master --force
Git Pages
Make sure you're in your branch
git checkout name_of_branch
Pull most recent copy
git pull
Add files and changes
git add -A
Commit files, changes and message
git commit -m "my message to myself and others"
Push the files to the repository branch
git push --set-upstream origin name_of_branch
Switching branches
git checkout name_of_branch
git pull
Merging Branches
Checkout Branch - In this case we're merging back to master
git checkout master
git pull
Merging the branch
git merge name_of_branch
Push the merge
git push origin master
Revert to commit including all files
Checkout branch to revert
git checkout name_of_branch
Reset to revision number
git reset --hard commit#
Clean up the files
git clean -fd
Add the reverted setup
git add -A
Commiting the reverted setup
git commit -m "reverting back all files to this"
Force add might be needed
git push origin master --force
Git Pages
Checkout branch to revert
git checkout name_of_branch
Reset to revision number
git reset --hard commit#
Clean up the files
git clean -fd
Add the reverted setup
git add -A
Commiting the reverted setup
git commit -m "reverting back all files to this"
Force add might be needed
git push origin master --force
Git Pages
Git pages are automatically hosted git repositories.
Github.com Repository Settings -> Automatic Page Generator
Select any theme, we'll merge our master repository with the github pages branch. Then our site will be deployed after
After setting up the page you'll notice a gh-pages branch with your repository
git branch
Checkout the gh-pages branch
git checkout gh-pages
Pull gh-pages files
git pull
Manually delete default files
Now merge in the master branch
git merge master
Add all the files
git add -A
Commit the files and message
git commit -m "merging master to gh-pages"
Pushing the files to the gh-pages branch
git push
Working with remote repositories
git remote add [name] [protocol://path.git]
git remote add wordpress https://github.com/WordPress/WordPress.git
A quick test to list all the repositories
git remote -v
This will list my repository as the origin and the WordPress repository as wordpress.
Remember, it's git remote add [name I've set] [path]
$git remote -v origin https://github.com/brandonbrule/my-repository.git (fetch) origin https://github.com/brandonbrule/my-repository.git (push) wordpress https://github.com/WordPress/WordPress.git (fetch) wordpress https://github.com/WordPress/WordPress.git (push)
git fetch
git fetch wordpress
This will do its git thing, and come back with a list of branches and tags from the WordPress repository.
Something like this will be returned.
* [new branch] 3.5-branch -> wordpress/3.5-branch * [new branch] 3.6-branch -> wordpress/3.6-branch * [new branch] 3.7-branch -> wordpress/3.7-branch * [new branch] 3.6-branch -> wordpress/3.6-branch * [new branch] master -> wordpress/master from https://github.com/WordPress/WordPress * [new tag] 1.5.1.2 -> 1.5.1.2 * [new tag] 2.0.1 -> 2.0.1 * [new tag] 2.5 -> 2.5
Now we'll pull in the files of the master branch.
pull = get files, push = transfer my changes
git pull wordpress master
And downloading of the files will begin.
git pull wordpress master
Git add / commit reminder
git add . git commit -m "I'm committing WordPress. Horray" git push origin master
git add .(all)
git commit -m "message"
git push origin(my-repository) master(master branch)