Skip to content

Working with Git and GitHub

Joe Cartonia edited this page Aug 6, 2020 · 1 revision

Git and GitHub basics

If you are new to using Git for version control, then please visit the following sites to learn about it:

Clone a repository

# Clone from a public repository using an HTTPS URL address
[ferris@bueller weforms-pro](master)$ git clone https://github.com/BoldGrid/weforms.git -b master

# Clone from a private repository using an SSH Git path
[ferris@bueller weforms-pro](master)$ git clone [email protected]:BoldGrid/weforms-pro.git -b master

Add an optional push address

There are times when you want to configure a public repository with the pull address using HTTPS and the push address using Git/SSH. When using this configuration, you can perform pulls without having to authenticate.

[ferris@bueller weforms-pro](master)$ git remote set-url --push [email protected]:BoldGrid/weforms.git

Create a feature/patch branch from the master branch

# Check the current working tree status.
[ferris@bueller myrepo](master)$ git status

# If not working in a clear tree, then stash, commit, or discard the changes.
[ferris@bueller myrepo](master)$ git checkout .

# Pull in any changes from the remote master branch.
[ferris@bueller myrepo](master)$ git pull origin master

# Create a new branch based on the master branch.
[ferris@bueller myrepo](master)$ git checkout -b my-branch

# Commit your changes.  You can reference GitHub issues by number using "Fixes #".
[ferris@bueller myrepo](my-branch)$ git commit -am 'Fixed bug.  Fixes #1'

# Push the commit(s) to the remote repository.
[ferris@bueller myrepo](my-branch)$ git push origin my-branch

Create a release tag

# Create the tag.
[ferris@bueller myrepo](my-branch)$ git tag -a 1.2.3 -m 'Patch release'

# Push tags to the remote repository.
[ferris@bueller myrepo](my-branch)$ git push --tags

Clone this wiki locally