SlideShare a Scribd company logo
BECKY TODD | LEAD CONTENT DESIGNER | @BECKATODD
Git the Docs
A fun, hands-on introduction to version control
Welcome!
We're here to help you learn how
to use Git.
@beckatodd | #WriteTheDocs
I am not a Git expert, but…!
@beckatodd | #WriteTheDocs
SETUP CHECK
https://bitbucket.org/beckytodd/learn-git-
wtd-aus-2019/src/master/resources/
1
2
3
Work ahead only if you dare...
Wait to run commands until instructed. Otherwise, you might get your working tree
into a wonky state.
Let us know if you get stuck.
Raise your hand if a command fails or if you get an unexpected result and don't know
how to fix it.
Ask questions.
Raise your hand if you have a question. We're here to help you learn.
Ground rules
@beckatodd | #WriteTheDocs
Agenda
Tools
Git concepts
Basic Git workflow
Beyond the basics
Resources
Bonus: Merge conflicts
@beckatodd | #WriteTheDocs
Tools
Hosting services, text editors, and the command line
@beckatodd | #WriteTheDocs
Hosting services
Software products that store Git repos
on a server
Git
A software program installed on your
computer
@beckatodd | #WriteTheDocs
GitHub
www.github.com
Hosting services
GitLab
https://about.gitlab.com/
Bitbucket
www.bitbucket.org
@beckatodd | #WriteTheDocs
Git Bash
Comes with Git for Windows
Command line utilities
Command line
Default Windows CLI
Terminal
Default macOS CLI
@beckatodd | #WriteTheDocs
Sublime Text Atom Visual Studio
Code
Vim
Cross-platform editors
@beckatodd | #WriteTheDocs
@beckatodd | #WriteTheDocs
Gitconcepts
Repos, workflows, and more
@beckatodd | #WriteTheDocs
VERSION CONTROL
A system that
records changes
over time.
@beckatodd | #WriteTheDocs
GIT REPOSITORY (REPO)
A container for
project files.
@beckatodd | #WriteTheDocs
PULL REQUEST
A web interface
for reviewing,
approving, and
merging changes.
@beckatodd | #WriteTheDocs
@beckatodd | #WriteTheDocs
Upstream
Fork
Fork Fork
@beckatodd | #WriteTheDocs
Basic workflow
1. create a branch
2. add our work (stage changes)
3. commit our work locally
4. push the branch to the remote repo (Bitbucket)
5. create a pull request (Bitbucket)
6. merge the changes into the master branch
7. pull changes from the remote repo
@beckatodd | #WriteTheDocs
Basic workflow
1. create a branch
6. merge the changes into the master branch
2. add our work (stage changes)
5. create a pull request (Bitbucket)
3. commit our work locally
4. push the branch to the remote repo (Bitbucket)
7. pull changes from the remote repo
@beckatodd | #WriteTheDocs
Basic Git workflow
Let’s "git" with it…
@beckatodd | #WriteTheDocs
1. Get help
@beckatodd | #WriteTheDocs
https://git-scm.com/docs
git -- help
Git’s documentation is
built in — try it for
yourself!
$ git --help
usage: git [--version] [--help] [-C <path>] [-c name=value]
[--exec-path[=<path>]] [--html-path] [--man-path] [--info-path]
[-p | --paginate | --no-pager] [--no-replace-objects] [--bare]
[--git-dir=<path>] [--work-tree=<path>] [--namespace=<name>]
<command> [<args>]
These are common Git commands used in various situations:
start a working area (see also: git help tutorial)
clone Clone a repository into a new directory
init Create an empty Git repository or reinitialize an existing one
work on the current change (see also: git help everyday)
add Add file contents to the index
mv Move or rename a file, a directory, or a symlink
reset Reset current HEAD to the specified state
rm Remove files from the working tree and from the index
examine the history and state (see also: git help revisions)
@beckatodd | #WriteTheDocs
2. Create a workspace
Workspace
setup
Make a folder named
repos in a root folder.
$ mkdir repos && cd repos
repos/ $
macOS
$ cd c:
$ mkdir repos && cd repos
/c/repos/ $
Windows
3. Fork the repo
@beckatodd | #WriteTheDocs
https://bitbucket.org/beckytodd/learn-git-wtd-aus-2019/
https://bitbucket.org/beckytodd/learn-git-wtd-aus-2019/
https://bitbucket.org/angie-wallaby/learn-git-wtd-aus-2019/
https://bitbucket.org/angie-wallaby/learn-git-wtd-aus-2019/
https://bitbucket.org/beckytodd/learn-git-wtd-aus-2019/
Upstream
Fork
Fork Fork
@beckatodd | #WriteTheDocs
4. Clone locally
@beckatodd | #WriteTheDocs
• Clones a repository into a newly created directory
• Creates remote-tracking branches for each branch in the cloned repository
(visible using git branch -r),
• Creates and checks out an initial branch that is forked from the cloned
repository's currently active branch (typically master).
$ git clone <remote-info>
@beckatodd | #WriteTheDocs
git clone
Clones your fork into
its own directory
inside repos/.
$ git clone git@bitbucket.org:angie-
wallaby/learn-git-wtd-aus-2019.git
Cloning into 'learn-git-wtd-aus-2019'...
Warning: Permanently added the RSA host key for IP address
'18.205.93.0' to the list of known hosts.
remote: Counting objects: 13, done.
remote: Compressing objects: 100% (9/9), done.
remote: Total 33 (delta 11), reused 0 (delta 0)
Receiving objects: 100% (13/13), 108.28 KiB | 1.14 MiBs,
done.
remote: Total 13 (delta 0), reuse 0 (delta0)
See what
happened
Switch to the learn-
git-wtd-aus-2019
directory, and list its
contents.
$ cd learn-git-wtd-aus-2019
exercise-one/ exercise-two/ LICENSE.txt resources/
$ ls
repos/learn-git-wtd-aus-2019/ $
$ open .
$ explorer .
5. Set up remotes
@beckatodd | #WriteTheDocs
We'll use three different arguments for the git remote command:
• -v to see the URLs of all remotes
• add <name> <url> to link to a new remote (upstream)
• set-url --push <name> <url> to disable the ability to push to the
upstream remote
$ git remote [various args]
@beckatodd | #WriteTheDocs
View remotes
Shows a list of
remotes associated
with your repo.
The -v argument
prints the URL after
the name.
$ git remote -v
origin git@bitbucket.org:angie-wallaby/learn-git-wtd-
aus-2019.git (fetch)
origin git@bitbucket.org:angie-wallaby/learn-git-wtd-
aus-2019.git (push)
Add
upstream
remote
Adds a connection to
the original repo,
which we're naming
upstream.
This command
requires the URL of
the main repo
(upstream).
$ git remote add upstream
git@bitbucket.org:beckytodd/learn-git-
wtd-aus-2019.git
View remotes
Shows a list of
remotes associated
with your repo.
The -v argument
prints the URL after
the name.
$ git remote -v
origin git@bitbucket.org:beckytodd/becky-learn-git-wtd-
aus-2019.git (fetch)
origin git@bitbucket.org:beckytodd/becky-learn-git-wtd-
aus-2019.git (push)
upstream git@bitbucket.org:beckytodd/learn-git-wtd-
aus-2019.git (fetch)
upstream git@bitbucket.org:beckytodd/learn-git-wtd-aus-
aus-2019.git (push)
Disable push
on upstream
remote
Updates the URL of
the remote named
upstream.
The --push argument
specifies that we
want to reset only the
URL associated with
the git push
command.
$ git remote set-url --push upstream
DISABLED
View remotes
Shows a list of
remotes associated
with your repo.
The -v argument
prints the URL after
the name.
$ git remote -v
origin git@bitbucket.org:beckytodd/becky-learn-git-wtd-
aus-2019.git (fetch)
origin git@bitbucket.org:beckytodd/becky-learn-git-wtd-
aus-2019.git (push)
upstream git@bitbucket.org:beckytodd/learn-git-wtd-
aus-2019.git (fetch)
upstream DISABLED (push)
git fetch
Gets updates from the
upstream repository.
$ git fetch upstream
From bitbucket.org:beckytodd/learn-git-wtd-aus-2019
* [new branch] master -> upstream/master
Upstream (upstream)
Fork (origin)
@beckatodd | #WriteTheDocs
Break time
(5 mins)
@beckatodd | #WriteTheDocs
6. Branch
@beckatodd | #WriteTheDocs
• Lists all branches (no args)
• <name> creates a new branch*
$ git branch [various args]
@beckatodd | #WriteTheDocs
git branch
View all local
branches.
$ git branch
* master
Always commit or stash changes before changing branches.
• <branch-name> specify a branch name to switch it
• -b <branch-name> to create a new branch AND switch to it
• -b <branch-name> <remote>/<branch> to create a new branch from
a branch on a specified remote (like upstream/master) AND switch to it
$ git checkout [various args]
🎉
• Cannot contain spaces
• Are case sensitive
• Should be short and descriptive
• Follow company style (for example, include issue numbers)
Branch names
git checkout 

-b
Create and checkout a
new branch for your
work.
$ git checkout -b <name>-first-branch
upstream/master
Switched to a new branch 'angiew-first-branch'
Your branch is up to date with 'upstream/master'
7. Edit the docs
@beckatodd | #WriteTheDocs
Edit your file
Open the file that has
your name on it, and
make a change or two.
../exercise-one/<file-name>.md
---
title: "About berries"
---
# About berries
Berries are small fruits. They come in all shapes and
sizes. Scientists define berries as "a fruit produced from
the ovary of a single flower in which the outer layer of
the ovary wall develops into an edible fleshy portion
(pericarp)."
There are a number of fruts that you wouldn't normally
think of as berries, such as:
- bananas
8. Add and commit
@beckatodd | #WriteTheDocs
Shows the status of the working tree:
• changed files
• deleted files
• new files (untracked)
• renamed (moved) files
• which files are staged (added)
$ git status
@beckatodd | #WriteTheDocs
git status
See the state of the
working tree.
$ git status
On branch angiew-first-branch
Your branch is up to date with 'upstream/master'
Changes not staged for commit:
(use "git add <file>..." to update what will be
committed)
(use "git checkout -- <file>..." to discard changes in
the working directory)
modified: exercise-one/<file-name>.md
no changes added to commit (use "git add"/or "git commit -
a")
• Adds the specified file(s) to staging
$ git add <file-name>
@beckatodd | #WriteTheDocs
git add
Add your file to stage
your changes.
$ git add exercise-one/<file-name>.md
On branch angiew-first-branch
Your branch is up to date with 'upstream/master'
Changes to be committed:
(use "git reset HEAD <file>..." to unstage)
modified: exercise-one/<file-name>.md
$ git status
git reset
Remove your file from
staging.
$ git reset exercise-one/<file-name>.md
On branch angiew-first-branch
Your branch is up to date with 'upstream/master'
Changes not staged for commit:
(use "git add <file>..." to update what will be
committed)
(use "git checkout -- <file>..." to discard changes in
the working directory)
modified: exercise-one/<file-name>.md
no changes added to commit (use "git add"/or "git commit -
a")
$ git status
git add
Add your file to stage
your changes.
$ git add exercise-one/<file-name>.md
On branch angiew-first-branch
Your branch is up to date with 'upstream/master'
Changes to be committed:
(use "git reset HEAD <file>..." to unstage)
modified: exercise-one/<file-name>.md
$ git status
• Write a commit message in editor, like Vim (no args)
• -m "Some message" write a commit message inline
$ git commit [various args]
@beckatodd | #WriteTheDocs
git commit
Use the -m argument
and add a commit
message in quotes.
$ git commit -m "Correcting spelling
errors and typos"
[angiew-first-branch 1ec8e60] Correcting spelling errors
and typos
1 file changed, 4 insertions(+), 4 deletions(-)
• Are associated with you
• Are kinda forever 💎
• Should be succinct and descriptive
• Follow company style (for example, include issue numbers)
• Line length limits may apply*
Commit messages
@beckatodd | #WriteTheDocs
• See the Git history in the command line
$ git log
@beckatodd | #WriteTheDocs
git log
See the git history in
the command line
interface.
$ git log
Commit d850bc4...(HEAD -> angiew-first-commit)
Author: Angie Wallaby <example-email@example.com>
Date: Wednesday November 13 12:03:58 2019 -0700
Correcting typos and spelling errors
Commit c845249... (upstream/master, origin/master, origin/
angiew-first-commit, origin/HEAD, master)
Merge: Becky Todd <btodd@atlassian.com>
Date: Wednesday November 13 13:01:14 2019 -0500
Merged wtd-class-set-up-merge-conflict into master
....
9. Push your work
@beckatodd | #WriteTheDocs
• Pushes the current branch to origin (no args)*
• <remote> <branch> specifies the exact remote and branch
$ git push [various args]
@beckatodd | #WriteTheDocs
git push
This command sends
a copy of all non-
pushed commits on
your branch to
Bitbucket.
$ git push origin <name>-first-branch
Enumerating objects: 7, done.
Counting objects: 100% (7.7), done.
Compressing objects: 100% (4/4), done.
Writing objects: 100% (4/4), 391 bytes | 0 bytes/s, done.
Total 4 (delta 3), reused 0 (delta 0)
remote:
remote: Create pull request for angiew-first-branch:
remote: https://bitbucket.org/angie-wallaby/learn-git-
wtd-aus-2019/pull-requests/new?source=angiew-first-
branch&t=1
remote:
To bitbucket.org:angie-wallaby/learn-git-wtd-aus-2019.git
* [new branch] angiew-first-branch -> angiew-first-branch
10. Create pull request
@beckatodd | #WriteTheDocs
• Use a descriptive title.
• Describe the changes you in the pull request.
• Indicate what you want the reviewers to review (for example, Please check
grammar and technical accuracy).
• Select reviewers who are responsible for approving and merging changes.
Pull requests
@beckatodd | #WriteTheDocs
Group activity: 

Create a pull request
@beckatodd | #WriteTheDocs
11. Keep in sync
@beckatodd | #WriteTheDocs
• Downloads objects from origin, without making local changes (no args)
• <remote> specifies the remote to download objects from
$ git fetch [various args]
@beckatodd | #WriteTheDocs
git fetch
Gets updates from the
upstream repository
(including branches),
along with the objects
associated with the
updates.
Tip: git fetch does
not make local
changes.
$ git fetch upstream
remote: Counting objects: 9, done.
remote: Compressing objects: 100% (9/9), done.
remote: Total 9 (delta 5), reused 0 (delta 0)
Unpacking objects: 100% (9/9), done.
From bitbucket.org:beckytodd/learn-git-wtd-aus-2019
* [new branch] dev-branch -> upstream/dev-branch
* [new branch] master -> upstream/master
• Incorporates objects into the current branch from origin (no args)*
• <remote> <branch> specifies the remote and branch to incorporate
objects from
$ git pull [various args]
@beckatodd | #WriteTheDocs
git checkout,
git pull
$ git checkout master
From bitbucket.org:beckytodd/learn-git-wtd-aus-2019
* branch master -> FETCH_HEAD
Updating 0d85853..435eeb2
Fast-forward
exercise-one/.DS_Store | Bin 6148 -> 0 bytes
exercise-one/<file-name>.md | 38 ++++++++++++++++++++++
++++++++++++++++
exercise-one/<other-file-name>.md | 38 ++++++++++++++++++++++
++++++++++++++++
merge-conflict/<another-file-name>.md | 7 -------
4 files changed, 76 insertions(+), 7 deletions(-)
delete mode 100644 exercise-one/.DS_Store
create mode 100644 exercise-one/<file-name>.md
create mode 100644 exercise-one/<other-file-name>.md
delete mode 100644 merge-conflict/<another-file-name>.md
$ git pull upstream master
git push
This command sends
a copy of all non-
pushed commits on
your version of the
master branch to
Bitbucket.
$ git push origin master
Enumerating objects: 7, done.
Counting objects: 100% (7/7), done.
Delta compression using up to 8 threads
Compressing objects: 100% (4/4), done.
Writing objects: 100% (4/4), 406 bytes | 406.00 KiB/s, done.
Total 4 (delta 2), reused 0 (delta 0)
To bitbucket.org:beckytodd/becky-learn-git-wtd-aus-2019.git
0d85853..435eeb2 master -> master
Break time
(5 mins)
@beckatodd | #WriteTheDocs
Questions
@beckatodd | #WriteTheDocs
Beyond basics
Best practices and additional Git commands
@beckatodd | #WriteTheDocs
Best practices
Tips, tricks, and advice
@beckatodd | #WriteTheDocs
DON'T BE AFRAID TO ADD,
COMMIT, AND PUSH OFTEN.
@beckatodd | #WriteTheDocs
A well-cared for [Git] log is a
beautiful and useful thing.
Chris Beams, https://chris.beams.io/posts/git-commit/
Git commands
Going beyond the basic workflow
@beckatodd | #WriteTheDocs
• Lists all branches (no args)
• <name> creates a new branch*
• -r shows you the remote associated with a branch
• -d or -D deletes the specified branch
$ git branch [various args]
@beckatodd | #WriteTheDocs
Delete a
branch
$ git branch -d <name>-first-branch
Deleted branch angiew-first-branch was (d850bc4)
• Show changes for all files that are unstaged (no args)
• --cached shows changes for files that have been staged (diff between last
commit and the staged changes)
• <file-name> shows changes for a specific file
$ git diff [various args]
@beckatodd | #WriteTheDocs
• Stashes all local changes (no args)
• list shows a list of all of your stashes and associated branches
• apply stash@{#} applies the changes saved in a specified stash to your
current branch
• drop stash@{#} drops the stash from Git
$ git stash [various args]
@beckatodd | #WriteTheDocs
THERE'S SO MUCH MORE.
I'M STILL LEARNING GIT,
EVEN 7+ YEARS LATER...
@beckatodd | #WriteTheDocs
Resources
Continue learning about Git and command line interfaces
Git skills and tools
Resources for further learning
@beckatodd | #WriteTheDocs
Read the manual
https://git-scm.com/doc
Learn Git branching - pcottle
http://learngitbranching.js.org/
Git tutorials - Atlassian
https://www.atlassian.com/git/tutorials/learn-git-with-bitbucket-cloud
Sourcetree (tool)
https://confluence.atlassian.com/get-started-with-sourcetree/install-and-set-up-sourcetree-847359043.html
Command line skills
Resources for leveling up your command line knowledge
@beckatodd | #WriteTheDocs
Learn the Command Line - Codecademy
https://www.codecademy.com/learn/learn-the-command-line
Open Vim (tutorial)
http://www.openvim.com/
Bonus: Merge conflicts
@beckatodd | #WriteTheDocs
12. Resolve merge conflict
@beckatodd | #WriteTheDocs
Questions
@beckatodd | #WriteTheDocs
Thank you!
BECKY TODD | LEAD DEVELOPER CONTENT DESIGNER | @BECKATODD

More Related Content

What's hot

Comparison of SVN and Git
Comparison of SVN and GitComparison of SVN and Git
Comparison of SVN and Git
Daniel Wieth
 
Git Lab Introduction
Git Lab IntroductionGit Lab Introduction
Git Lab Introduction
Krunal Doshi
 
Git and Github
Git and GithubGit and Github
Git and Github
Teodora Ahkozidou
 
Git and GitHub
Git and GitHubGit and GitHub
Git and GitHub
James Gray
 
Source control
Source controlSource control
Source control
Sachithra Gayan
 
Github - Git Training Slides: Foundations
Github - Git Training Slides: FoundationsGithub - Git Training Slides: Foundations
Github - Git Training Slides: Foundations
Lee Hanxue
 
Git and GitHub
Git and GitHubGit and GitHub
Git and GitHub
Md. Ahsan Habib Nayan
 
Testing Persistent Storage Performance in Kubernetes with Sherlock
Testing Persistent Storage Performance in Kubernetes with SherlockTesting Persistent Storage Performance in Kubernetes with Sherlock
Testing Persistent Storage Performance in Kubernetes with Sherlock
ScyllaDB
 
Git 101 for Beginners
Git 101 for Beginners Git 101 for Beginners
Git 101 for Beginners
Anurag Upadhaya
 
Git and Github Session
Git and Github SessionGit and Github Session
Git and Github Session
GoogleDevelopersStud1
 
Intro to Git, GitHub, and BitBucket
Intro to Git, GitHub, and BitBucketIntro to Git, GitHub, and BitBucket
Introduction to git & GitHub
Introduction to git & GitHubIntroduction to git & GitHub
Introduction to git & GitHub
Poornachandrakashi
 
Git - Basic Crash Course
Git - Basic Crash CourseGit - Basic Crash Course
Git - Basic Crash Course
Nilay Binjola
 
Version control
Version controlVersion control
Version control
visual28
 
Introduction to github slideshare
Introduction to github slideshareIntroduction to github slideshare
Introduction to github slideshare
Rakesh Sukumar
 
Git Series. Episode 3. Git Flow and Github-Flow
Git Series. Episode 3. Git Flow and Github-FlowGit Series. Episode 3. Git Flow and Github-Flow
Git Series. Episode 3. Git Flow and Github-Flow
Mikhail Melnik
 
Git and github 101
Git and github 101Git and github 101
Git and github 101
Senthilkumar Gopal
 
Git basics
Git basicsGit basics
Git basics
GHARSALLAH Mohamed
 
Version Control System
Version Control SystemVersion Control System
Version Control System
guptaanil
 

What's hot (20)

Comparison of SVN and Git
Comparison of SVN and GitComparison of SVN and Git
Comparison of SVN and Git
 
Git Lab Introduction
Git Lab IntroductionGit Lab Introduction
Git Lab Introduction
 
GIT_In_90_Minutes
GIT_In_90_MinutesGIT_In_90_Minutes
GIT_In_90_Minutes
 
Git and Github
Git and GithubGit and Github
Git and Github
 
Git and GitHub
Git and GitHubGit and GitHub
Git and GitHub
 
Source control
Source controlSource control
Source control
 
Github - Git Training Slides: Foundations
Github - Git Training Slides: FoundationsGithub - Git Training Slides: Foundations
Github - Git Training Slides: Foundations
 
Git and GitHub
Git and GitHubGit and GitHub
Git and GitHub
 
Testing Persistent Storage Performance in Kubernetes with Sherlock
Testing Persistent Storage Performance in Kubernetes with SherlockTesting Persistent Storage Performance in Kubernetes with Sherlock
Testing Persistent Storage Performance in Kubernetes with Sherlock
 
Git 101 for Beginners
Git 101 for Beginners Git 101 for Beginners
Git 101 for Beginners
 
Git and Github Session
Git and Github SessionGit and Github Session
Git and Github Session
 
Intro to Git, GitHub, and BitBucket
Intro to Git, GitHub, and BitBucketIntro to Git, GitHub, and BitBucket
Intro to Git, GitHub, and BitBucket
 
Introduction to git & GitHub
Introduction to git & GitHubIntroduction to git & GitHub
Introduction to git & GitHub
 
Git - Basic Crash Course
Git - Basic Crash CourseGit - Basic Crash Course
Git - Basic Crash Course
 
Version control
Version controlVersion control
Version control
 
Introduction to github slideshare
Introduction to github slideshareIntroduction to github slideshare
Introduction to github slideshare
 
Git Series. Episode 3. Git Flow and Github-Flow
Git Series. Episode 3. Git Flow and Github-FlowGit Series. Episode 3. Git Flow and Github-Flow
Git Series. Episode 3. Git Flow and Github-Flow
 
Git and github 101
Git and github 101Git and github 101
Git and github 101
 
Git basics
Git basicsGit basics
Git basics
 
Version Control System
Version Control SystemVersion Control System
Version Control System
 

Similar to Git the Docs: A fun, hands-on introduction to version control

簡單介紹git
簡單介紹git簡單介紹git
簡單介紹git
Grace Chien
 
Becoming a Git Master
Becoming a Git MasterBecoming a Git Master
Becoming a Git Master
Nicola Paolucci
 
Git Distributed Version Control System
Git   Distributed Version Control SystemGit   Distributed Version Control System
Git Distributed Version Control SystemVictor Wong
 
Git basics
Git basicsGit basics
Git basics
Amit Sawhney
 
Introducción a git y GitHub
Introducción a git y GitHubIntroducción a git y GitHub
Introducción a git y GitHub
Lucas Videla
 
Git Started With Git
Git Started With GitGit Started With Git
Git Started With Git
Nick Quaranto
 
Gitting It Under (Version) Control
Gitting It Under (Version) ControlGitting It Under (Version) Control
Gitting It Under (Version) Controlmobiledevnj
 
Understanding about git
Understanding about gitUnderstanding about git
Understanding about git
Sothearin Ren
 
Introduction To Git Workshop
Introduction To Git WorkshopIntroduction To Git Workshop
Introduction To Git Workshop
themystic_ca
 
390a gitintro 12au
390a gitintro 12au390a gitintro 12au
390a gitintro 12au
Nguyen Van Hung
 
Practical git for developers
Practical git for developersPractical git for developers
Practical git for developers
Wim Godden
 
Git basic
Git basicGit basic
Git basic
Akbar Uddin
 
Git
GitGit
Git setuplinux
Git setuplinuxGit setuplinux
Git setuplinux
Shubham Verma
 
Getting some Git
Getting some GitGetting some Git
Getting some Git
BADR
 
Git presentation
Git presentationGit presentation
Git presentation
James Cuzella
 
Working in Team using Git in Unity
Working in Team using Git in UnityWorking in Team using Git in Unity
Working in Team using Git in Unity
Rifauddin Tsalitsy
 

Similar to Git the Docs: A fun, hands-on introduction to version control (20)

簡單介紹git
簡單介紹git簡單介紹git
簡單介紹git
 
Becoming a Git Master
Becoming a Git MasterBecoming a Git Master
Becoming a Git Master
 
Git Distributed Version Control System
Git   Distributed Version Control SystemGit   Distributed Version Control System
Git Distributed Version Control System
 
Gittalk
GittalkGittalk
Gittalk
 
Git basics
Git basicsGit basics
Git basics
 
Introducción a git y GitHub
Introducción a git y GitHubIntroducción a git y GitHub
Introducción a git y GitHub
 
Git Started With Git
Git Started With GitGit Started With Git
Git Started With Git
 
Gitting It Under (Version) Control
Gitting It Under (Version) ControlGitting It Under (Version) Control
Gitting It Under (Version) Control
 
Understanding about git
Understanding about gitUnderstanding about git
Understanding about git
 
Introduction To Git Workshop
Introduction To Git WorkshopIntroduction To Git Workshop
Introduction To Git Workshop
 
390a gitintro 12au
390a gitintro 12au390a gitintro 12au
390a gitintro 12au
 
Practical git for developers
Practical git for developersPractical git for developers
Practical git for developers
 
Loading...git
Loading...gitLoading...git
Loading...git
 
Git basic
Git basicGit basic
Git basic
 
Git
GitGit
Git
 
GitSetupLinux
GitSetupLinuxGitSetupLinux
GitSetupLinux
 
Git setuplinux
Git setuplinuxGit setuplinux
Git setuplinux
 
Getting some Git
Getting some GitGetting some Git
Getting some Git
 
Git presentation
Git presentationGit presentation
Git presentation
 
Working in Team using Git in Unity
Working in Team using Git in UnityWorking in Team using Git in Unity
Working in Team using Git in Unity
 

Recently uploaded

LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
DanBrown980551
 
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdfFIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance
 
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
UiPathCommunity
 
Monitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR EventsMonitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR Events
Ana-Maria Mihalceanu
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
Alan Dix
 
How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...
Product School
 
UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3
DianaGray10
 
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Albert Hoitingh
 
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
BookNet Canada
 
The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
Jemma Hussein Allen
 
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
Product School
 
Essentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with ParametersEssentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with Parameters
Safe Software
 
Knowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and backKnowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and back
Elena Simperl
 
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Thierry Lestable
 
JMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and GrafanaJMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and Grafana
RTTS
 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
Kari Kakkonen
 
UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4
DianaGray10
 
Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !
KatiaHIMEUR1
 
Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*
Frank van Harmelen
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
Guy Korland
 

Recently uploaded (20)

LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
 
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdfFIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
 
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
 
Monitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR EventsMonitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR Events
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
 
How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...
 
UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3
 
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
 
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
 
The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
 
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
 
Essentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with ParametersEssentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with Parameters
 
Knowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and backKnowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and back
 
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
 
JMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and GrafanaJMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and Grafana
 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
 
UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4
 
Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !
 
Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
 

Git the Docs: A fun, hands-on introduction to version control

  • 1. BECKY TODD | LEAD CONTENT DESIGNER | @BECKATODD Git the Docs A fun, hands-on introduction to version control
  • 2. Welcome! We're here to help you learn how to use Git. @beckatodd | #WriteTheDocs
  • 3. I am not a Git expert, but…! @beckatodd | #WriteTheDocs
  • 6. 1 2 3 Work ahead only if you dare... Wait to run commands until instructed. Otherwise, you might get your working tree into a wonky state. Let us know if you get stuck. Raise your hand if a command fails or if you get an unexpected result and don't know how to fix it. Ask questions. Raise your hand if you have a question. We're here to help you learn. Ground rules @beckatodd | #WriteTheDocs
  • 7. Agenda Tools Git concepts Basic Git workflow Beyond the basics Resources Bonus: Merge conflicts @beckatodd | #WriteTheDocs
  • 8. Tools Hosting services, text editors, and the command line @beckatodd | #WriteTheDocs
  • 9. Hosting services Software products that store Git repos on a server Git A software program installed on your computer @beckatodd | #WriteTheDocs
  • 11. Git Bash Comes with Git for Windows Command line utilities Command line Default Windows CLI Terminal Default macOS CLI @beckatodd | #WriteTheDocs
  • 12. Sublime Text Atom Visual Studio Code Vim Cross-platform editors @beckatodd | #WriteTheDocs
  • 14. Gitconcepts Repos, workflows, and more @beckatodd | #WriteTheDocs
  • 15. VERSION CONTROL A system that records changes over time. @beckatodd | #WriteTheDocs
  • 16. GIT REPOSITORY (REPO) A container for project files. @beckatodd | #WriteTheDocs
  • 17. PULL REQUEST A web interface for reviewing, approving, and merging changes. @beckatodd | #WriteTheDocs
  • 20. Basic workflow 1. create a branch 2. add our work (stage changes) 3. commit our work locally 4. push the branch to the remote repo (Bitbucket) 5. create a pull request (Bitbucket) 6. merge the changes into the master branch 7. pull changes from the remote repo @beckatodd | #WriteTheDocs
  • 21. Basic workflow 1. create a branch 6. merge the changes into the master branch 2. add our work (stage changes) 5. create a pull request (Bitbucket) 3. commit our work locally 4. push the branch to the remote repo (Bitbucket) 7. pull changes from the remote repo @beckatodd | #WriteTheDocs
  • 22. Basic Git workflow Let’s "git" with it… @beckatodd | #WriteTheDocs
  • 23. 1. Get help @beckatodd | #WriteTheDocs
  • 25. git -- help Git’s documentation is built in — try it for yourself! $ git --help usage: git [--version] [--help] [-C <path>] [-c name=value] [--exec-path[=<path>]] [--html-path] [--man-path] [--info-path] [-p | --paginate | --no-pager] [--no-replace-objects] [--bare] [--git-dir=<path>] [--work-tree=<path>] [--namespace=<name>] <command> [<args>] These are common Git commands used in various situations: start a working area (see also: git help tutorial) clone Clone a repository into a new directory init Create an empty Git repository or reinitialize an existing one work on the current change (see also: git help everyday) add Add file contents to the index mv Move or rename a file, a directory, or a symlink reset Reset current HEAD to the specified state rm Remove files from the working tree and from the index examine the history and state (see also: git help revisions)
  • 26. @beckatodd | #WriteTheDocs 2. Create a workspace
  • 27. Workspace setup Make a folder named repos in a root folder. $ mkdir repos && cd repos repos/ $ macOS $ cd c: $ mkdir repos && cd repos /c/repos/ $ Windows
  • 28. 3. Fork the repo @beckatodd | #WriteTheDocs
  • 31.
  • 36. 4. Clone locally @beckatodd | #WriteTheDocs
  • 37. • Clones a repository into a newly created directory • Creates remote-tracking branches for each branch in the cloned repository (visible using git branch -r), • Creates and checks out an initial branch that is forked from the cloned repository's currently active branch (typically master). $ git clone <remote-info> @beckatodd | #WriteTheDocs
  • 38.
  • 39.
  • 40. git clone Clones your fork into its own directory inside repos/. $ git clone git@bitbucket.org:angie- wallaby/learn-git-wtd-aus-2019.git Cloning into 'learn-git-wtd-aus-2019'... Warning: Permanently added the RSA host key for IP address '18.205.93.0' to the list of known hosts. remote: Counting objects: 13, done. remote: Compressing objects: 100% (9/9), done. remote: Total 33 (delta 11), reused 0 (delta 0) Receiving objects: 100% (13/13), 108.28 KiB | 1.14 MiBs, done. remote: Total 13 (delta 0), reuse 0 (delta0)
  • 41. See what happened Switch to the learn- git-wtd-aus-2019 directory, and list its contents. $ cd learn-git-wtd-aus-2019 exercise-one/ exercise-two/ LICENSE.txt resources/ $ ls repos/learn-git-wtd-aus-2019/ $ $ open . $ explorer .
  • 42. 5. Set up remotes @beckatodd | #WriteTheDocs
  • 43. We'll use three different arguments for the git remote command: • -v to see the URLs of all remotes • add <name> <url> to link to a new remote (upstream) • set-url --push <name> <url> to disable the ability to push to the upstream remote $ git remote [various args] @beckatodd | #WriteTheDocs
  • 44. View remotes Shows a list of remotes associated with your repo. The -v argument prints the URL after the name. $ git remote -v origin git@bitbucket.org:angie-wallaby/learn-git-wtd- aus-2019.git (fetch) origin git@bitbucket.org:angie-wallaby/learn-git-wtd- aus-2019.git (push)
  • 45. Add upstream remote Adds a connection to the original repo, which we're naming upstream. This command requires the URL of the main repo (upstream). $ git remote add upstream git@bitbucket.org:beckytodd/learn-git- wtd-aus-2019.git
  • 46. View remotes Shows a list of remotes associated with your repo. The -v argument prints the URL after the name. $ git remote -v origin git@bitbucket.org:beckytodd/becky-learn-git-wtd- aus-2019.git (fetch) origin git@bitbucket.org:beckytodd/becky-learn-git-wtd- aus-2019.git (push) upstream git@bitbucket.org:beckytodd/learn-git-wtd- aus-2019.git (fetch) upstream git@bitbucket.org:beckytodd/learn-git-wtd-aus- aus-2019.git (push)
  • 47. Disable push on upstream remote Updates the URL of the remote named upstream. The --push argument specifies that we want to reset only the URL associated with the git push command. $ git remote set-url --push upstream DISABLED
  • 48. View remotes Shows a list of remotes associated with your repo. The -v argument prints the URL after the name. $ git remote -v origin git@bitbucket.org:beckytodd/becky-learn-git-wtd- aus-2019.git (fetch) origin git@bitbucket.org:beckytodd/becky-learn-git-wtd- aus-2019.git (push) upstream git@bitbucket.org:beckytodd/learn-git-wtd- aus-2019.git (fetch) upstream DISABLED (push)
  • 49. git fetch Gets updates from the upstream repository. $ git fetch upstream From bitbucket.org:beckytodd/learn-git-wtd-aus-2019 * [new branch] master -> upstream/master
  • 52. 6. Branch @beckatodd | #WriteTheDocs
  • 53. • Lists all branches (no args) • <name> creates a new branch* $ git branch [various args] @beckatodd | #WriteTheDocs
  • 54. git branch View all local branches. $ git branch * master
  • 55. Always commit or stash changes before changing branches. • <branch-name> specify a branch name to switch it • -b <branch-name> to create a new branch AND switch to it • -b <branch-name> <remote>/<branch> to create a new branch from a branch on a specified remote (like upstream/master) AND switch to it $ git checkout [various args] 🎉
  • 56. • Cannot contain spaces • Are case sensitive • Should be short and descriptive • Follow company style (for example, include issue numbers) Branch names
  • 57. git checkout 
 -b Create and checkout a new branch for your work. $ git checkout -b <name>-first-branch upstream/master Switched to a new branch 'angiew-first-branch' Your branch is up to date with 'upstream/master'
  • 58. 7. Edit the docs @beckatodd | #WriteTheDocs
  • 59. Edit your file Open the file that has your name on it, and make a change or two. ../exercise-one/<file-name>.md --- title: "About berries" --- # About berries Berries are small fruits. They come in all shapes and sizes. Scientists define berries as "a fruit produced from the ovary of a single flower in which the outer layer of the ovary wall develops into an edible fleshy portion (pericarp)." There are a number of fruts that you wouldn't normally think of as berries, such as: - bananas
  • 60. 8. Add and commit @beckatodd | #WriteTheDocs
  • 61. Shows the status of the working tree: • changed files • deleted files • new files (untracked) • renamed (moved) files • which files are staged (added) $ git status @beckatodd | #WriteTheDocs
  • 62. git status See the state of the working tree. $ git status On branch angiew-first-branch Your branch is up to date with 'upstream/master' Changes not staged for commit: (use "git add <file>..." to update what will be committed) (use "git checkout -- <file>..." to discard changes in the working directory) modified: exercise-one/<file-name>.md no changes added to commit (use "git add"/or "git commit - a")
  • 63. • Adds the specified file(s) to staging $ git add <file-name> @beckatodd | #WriteTheDocs
  • 64. git add Add your file to stage your changes. $ git add exercise-one/<file-name>.md On branch angiew-first-branch Your branch is up to date with 'upstream/master' Changes to be committed: (use "git reset HEAD <file>..." to unstage) modified: exercise-one/<file-name>.md $ git status
  • 65. git reset Remove your file from staging. $ git reset exercise-one/<file-name>.md On branch angiew-first-branch Your branch is up to date with 'upstream/master' Changes not staged for commit: (use "git add <file>..." to update what will be committed) (use "git checkout -- <file>..." to discard changes in the working directory) modified: exercise-one/<file-name>.md no changes added to commit (use "git add"/or "git commit - a") $ git status
  • 66. git add Add your file to stage your changes. $ git add exercise-one/<file-name>.md On branch angiew-first-branch Your branch is up to date with 'upstream/master' Changes to be committed: (use "git reset HEAD <file>..." to unstage) modified: exercise-one/<file-name>.md $ git status
  • 67. • Write a commit message in editor, like Vim (no args) • -m "Some message" write a commit message inline $ git commit [various args] @beckatodd | #WriteTheDocs
  • 68. git commit Use the -m argument and add a commit message in quotes. $ git commit -m "Correcting spelling errors and typos" [angiew-first-branch 1ec8e60] Correcting spelling errors and typos 1 file changed, 4 insertions(+), 4 deletions(-)
  • 69. • Are associated with you • Are kinda forever 💎 • Should be succinct and descriptive • Follow company style (for example, include issue numbers) • Line length limits may apply* Commit messages @beckatodd | #WriteTheDocs
  • 70. • See the Git history in the command line $ git log @beckatodd | #WriteTheDocs
  • 71. git log See the git history in the command line interface. $ git log Commit d850bc4...(HEAD -> angiew-first-commit) Author: Angie Wallaby <example-email@example.com> Date: Wednesday November 13 12:03:58 2019 -0700 Correcting typos and spelling errors Commit c845249... (upstream/master, origin/master, origin/ angiew-first-commit, origin/HEAD, master) Merge: Becky Todd <btodd@atlassian.com> Date: Wednesday November 13 13:01:14 2019 -0500 Merged wtd-class-set-up-merge-conflict into master ....
  • 72. 9. Push your work @beckatodd | #WriteTheDocs
  • 73. • Pushes the current branch to origin (no args)* • <remote> <branch> specifies the exact remote and branch $ git push [various args] @beckatodd | #WriteTheDocs
  • 74. git push This command sends a copy of all non- pushed commits on your branch to Bitbucket. $ git push origin <name>-first-branch Enumerating objects: 7, done. Counting objects: 100% (7.7), done. Compressing objects: 100% (4/4), done. Writing objects: 100% (4/4), 391 bytes | 0 bytes/s, done. Total 4 (delta 3), reused 0 (delta 0) remote: remote: Create pull request for angiew-first-branch: remote: https://bitbucket.org/angie-wallaby/learn-git- wtd-aus-2019/pull-requests/new?source=angiew-first- branch&t=1 remote: To bitbucket.org:angie-wallaby/learn-git-wtd-aus-2019.git * [new branch] angiew-first-branch -> angiew-first-branch
  • 75. 10. Create pull request @beckatodd | #WriteTheDocs
  • 76. • Use a descriptive title. • Describe the changes you in the pull request. • Indicate what you want the reviewers to review (for example, Please check grammar and technical accuracy). • Select reviewers who are responsible for approving and merging changes. Pull requests @beckatodd | #WriteTheDocs
  • 77. Group activity: 
 Create a pull request @beckatodd | #WriteTheDocs
  • 78. 11. Keep in sync @beckatodd | #WriteTheDocs
  • 79. • Downloads objects from origin, without making local changes (no args) • <remote> specifies the remote to download objects from $ git fetch [various args] @beckatodd | #WriteTheDocs
  • 80. git fetch Gets updates from the upstream repository (including branches), along with the objects associated with the updates. Tip: git fetch does not make local changes. $ git fetch upstream remote: Counting objects: 9, done. remote: Compressing objects: 100% (9/9), done. remote: Total 9 (delta 5), reused 0 (delta 0) Unpacking objects: 100% (9/9), done. From bitbucket.org:beckytodd/learn-git-wtd-aus-2019 * [new branch] dev-branch -> upstream/dev-branch * [new branch] master -> upstream/master
  • 81. • Incorporates objects into the current branch from origin (no args)* • <remote> <branch> specifies the remote and branch to incorporate objects from $ git pull [various args] @beckatodd | #WriteTheDocs
  • 82. git checkout, git pull $ git checkout master From bitbucket.org:beckytodd/learn-git-wtd-aus-2019 * branch master -> FETCH_HEAD Updating 0d85853..435eeb2 Fast-forward exercise-one/.DS_Store | Bin 6148 -> 0 bytes exercise-one/<file-name>.md | 38 ++++++++++++++++++++++ ++++++++++++++++ exercise-one/<other-file-name>.md | 38 ++++++++++++++++++++++ ++++++++++++++++ merge-conflict/<another-file-name>.md | 7 ------- 4 files changed, 76 insertions(+), 7 deletions(-) delete mode 100644 exercise-one/.DS_Store create mode 100644 exercise-one/<file-name>.md create mode 100644 exercise-one/<other-file-name>.md delete mode 100644 merge-conflict/<another-file-name>.md $ git pull upstream master
  • 83. git push This command sends a copy of all non- pushed commits on your version of the master branch to Bitbucket. $ git push origin master Enumerating objects: 7, done. Counting objects: 100% (7/7), done. Delta compression using up to 8 threads Compressing objects: 100% (4/4), done. Writing objects: 100% (4/4), 406 bytes | 406.00 KiB/s, done. Total 4 (delta 2), reused 0 (delta 0) To bitbucket.org:beckytodd/becky-learn-git-wtd-aus-2019.git 0d85853..435eeb2 master -> master
  • 86. Beyond basics Best practices and additional Git commands @beckatodd | #WriteTheDocs
  • 87. Best practices Tips, tricks, and advice @beckatodd | #WriteTheDocs
  • 88. DON'T BE AFRAID TO ADD, COMMIT, AND PUSH OFTEN. @beckatodd | #WriteTheDocs
  • 89. A well-cared for [Git] log is a beautiful and useful thing. Chris Beams, https://chris.beams.io/posts/git-commit/
  • 90. Git commands Going beyond the basic workflow @beckatodd | #WriteTheDocs
  • 91. • Lists all branches (no args) • <name> creates a new branch* • -r shows you the remote associated with a branch • -d or -D deletes the specified branch $ git branch [various args] @beckatodd | #WriteTheDocs
  • 92. Delete a branch $ git branch -d <name>-first-branch Deleted branch angiew-first-branch was (d850bc4)
  • 93. • Show changes for all files that are unstaged (no args) • --cached shows changes for files that have been staged (diff between last commit and the staged changes) • <file-name> shows changes for a specific file $ git diff [various args] @beckatodd | #WriteTheDocs
  • 94. • Stashes all local changes (no args) • list shows a list of all of your stashes and associated branches • apply stash@{#} applies the changes saved in a specified stash to your current branch • drop stash@{#} drops the stash from Git $ git stash [various args] @beckatodd | #WriteTheDocs
  • 95. THERE'S SO MUCH MORE. I'M STILL LEARNING GIT, EVEN 7+ YEARS LATER... @beckatodd | #WriteTheDocs
  • 96. Resources Continue learning about Git and command line interfaces
  • 97. Git skills and tools Resources for further learning @beckatodd | #WriteTheDocs
  • 99. Learn Git branching - pcottle http://learngitbranching.js.org/
  • 100. Git tutorials - Atlassian https://www.atlassian.com/git/tutorials/learn-git-with-bitbucket-cloud
  • 102. Command line skills Resources for leveling up your command line knowledge @beckatodd | #WriteTheDocs
  • 103. Learn the Command Line - Codecademy https://www.codecademy.com/learn/learn-the-command-line
  • 106. 12. Resolve merge conflict @beckatodd | #WriteTheDocs
  • 107.
  • 109. Thank you! BECKY TODD | LEAD DEVELOPER CONTENT DESIGNER | @BECKATODD