intro to git, github, and bitbucket

41
Using Git, GitHub, & BitBucket Gwen Daniels Illinois Legal Aid Online [email protected]

Upload: legal-services-national-technology-assistance-project-lsntap

Post on 10-Feb-2017

270 views

Category:

Technology


3 download

TRANSCRIPT

Using Git, GitHub, & BitBucket

Gwen DanielsIllinois Legal Aid [email protected]

Who are you?

Survey Question

Which of these describe how you use Drupal?

Our program website runs on Drupal

Our statewide website runs on Open Advocate

Our statewide website runs on Drupal, but not Open Advocate

We don’t use Drupal

How would you describe your role on the website(s)?

I write code/custom modules for the website

I install contributed modules, install security updates on the website or edit configuration information in Drupal’s user interface (for example, creating content types, adding fields or changing permissions.

I’m a project manager; I sometimes have to deal with developers who work on our website

I’m a content manager

None of these apply to me; I just want to know a bit more about Git.

What We’re Covering

What is Git and why you should be using it

Git setup and options

Git commands

Git hosting with GitHub and Bitbucket

Where to go next

What is Git?Code management

tool

Version control

Distributed

Why Use Git?For our own projects

Acts as a backup

It lets us undo changes

It promotes collaboration

It organizes

To take advantage of other projects

But I’m not a developer!

Drupal sites have probably have at least 2 of these:

Custom modules

Contributed modules

Core modules

In Drupal 8: Configuration lives in code, not the database.

In Drupal 7, configuration lives in the database but can (and should) live in code via Features.

How Do I Work With

Git?

Command line

Using a GUI

GitHub client

SourceTree

Within your development IDE (PhpStorm, NetBeans, Eclipse, Sublime Text)

Getting Git

For Windows:

Download from https://git-scm.com or

Install a GUI like GitHub or Sourcetree

For Mac

Open Terminal and type git; you’ll be prompted to install the Xcode command line tools OR

Same options as Windows

For Linux:

sudo yum install git-all or sudo apt-get install git-all

The Git process

Demo

Walking through Git: Common Tasks

Git init: Create a Git repository

Git clone: to copy an existing repo with git clone

Git add: to add files to Git

Git commit: to commit those files to your local copy

Add -m and a message and describe what you did: git commit -m ‘I did something’

Walking through Git: Interacting with Remote Repositories

Add a remote repository using git remote add [name] [url]

Git pull: Push your commits to the remote repository

Git push: Pull the latest changes from the remote repository

Keeping track of things...

Get help with git --help or git --help command

See with list of files you’ve changed with git status

View your commit history with git log (or git log remote/branch)

Compare changes with git diff

Advanced Git

Using BranchesBy default, everything is in the Master branch

Branches let you:

Keep the master branch clean of “in development” code changes

Makes a copy of the then-existing master branch

All work is then done in the new branch

Only commit to master when you are done

You can publish your branch to share

Working with branches

Get a list of branches using git branch

Create a branch using git branch [branch name]

Delete a branch using git branch -d [branch name]

Merge your branch git merge master [branch name]

Tags

Tags let you:

Mark a specific point in time

Is essentially a branch that you can not change

List all your tags with git tag

Create a new tag with git tag ‘name’ -m ‘message’

Push a tag with git push origin ‘name’

Reverting changes

Use git checkout -- . or git reset --hard HEAD to revert any uncommitted file back to the current state

Use git checkout [commit] [file] to change your local working copy to an old version. [File] is optional.

Use git revert [commit] to undo all the work in that commit and create a new commit undoing those changes

GitHub & Bitbucket

What are Github and BitBucket?

Cloud-hosted repositories

Public and private repositories

Both offer additional tools:

Issue tracking

Wikis

Nice user interfaces

Webhooks and services to integrate with other systems

Differences

GitHub

Integrates well with the Github client

Free for public repositories

Private repositories start at $7/month

Nonprofit pricing

Bitbucket

Integrates well with SourceTree

Free for public repositories and small teams (less than 5 people)

Seamless integration with other Atlassian products, like Jira

GithubHome of many open source

projects

DLaw

Q & A markup

Learn the Law

Jonathan Pyle’s DocAssemble

Code Repository

Create or switch branches

Add new file, upload files

View, or edit files live in the browser

Manage Your Issues

Creating an issue

Email notifications

Pull Requests

GitHub Wiki

BitBucket

Source

Create or change branches

Online Editing…

Issue Tracking

Pull Requests

Wiki

Learn More…

Try git in the cloud: https://try.github.io/levels/1/challenges/1

Git Cheat Sheet: https://www.git-tower.com/blog/git-cheat-sheet/

Git Workflows: https://www.atlassian.com/git/tutorials/comparing-workflows/

Slides at: