For Beginners
In Three Acts
Git gives you options in how you you run your own daily workflow and coordinate with team members.
KEY DIFFERENTIATORS
Git: a set of Commands to manage source control
git clone
git status
git pull
git checkout
git branch
git merge
git push
Gits' got tools
GitHub Website
great for open source
Command Line Interface
OK not really a tool, just the raw commands
Desktop UI Tools
source-tree; unGit; gitKraken, ...
Integrated into IDE's
VS, VSCode, Atom ...
GitFlow is a set of macros that make it easy to use Git. High level commands mean fewer decisions less error prone repo management while developing a feature, fixing a bug or releasing a product.
GitFlow is opinionated. It dictates the use of branches in specific ways.
GitFlow is the automatic-transmission of repository management (don't worry about the inner mechanism and all those gear shifting details).
GitFlow
GitFlow has three core branches named:
and helper branches:
GitFlow
GitFlow
GitFlow
source: https://danielkummer.github.io/git-flow-cheatsheet/
Time for a release into the various test environments.
GitFlow
source: https://danielkummer.github.io/git-flow-cheatsheet/
An 'issue' is found in production and it needs to be fixed ASAP.
GitFlow
source: https://danielkummer.github.io/git-flow-cheatsheet/
GitFlow
source: https://www.atlassian.com/software/sourcetree
GitFlow
source: https://www.atlassian.com/software/sourcetree
GitFlow
source: https://www.atlassian.com/software/sourcetree
Why can't we go back to the good old days?
Nobody Wants That!
Git basics
git init is one way to get things started.
For example let's make a repository for "contracts."
OR
clone an existing repo making a local copy.
> mkdir contracts
> cd contracts
> git init
OR
> git clone https:url.of/repo
Git basics
git status has no affect on your repo. so never worry about asking git for status.
I ask all the time and so do the UI tools...
> git status
On branch master
Initial commit
nothing to commit (create/copy files and use "git add" to track)
Git basics
We are on the master branch. Let's see all branches and make a new branch (our own work space off to the side).
now checkout the new branch
> git branch --list
* master
> git branch dev
> git branch --list
dev
* master
> git checkout dev
Switched to branch 'dev'
Git basics
Teams members should adopt a work pattern:
============ time to code ==============
checkout the correct branch for your task*
pull from origin (remote => local) pulling in others work.
pull again (a pull includes a merge)***
push your commits back up to the origin (local => remote)
====== take a rest, or get back to work =====
Git basics
commit is the best thing to do if you want to make a record of your modified files
stash is the thing to do if you are fearful that the modification may not be the best way forward, but you are not ready to discard them completely
Git basics
If you wish you had been working on a different branch, here is one way to fix that.
don't commit your code, instead
git stash --save , then
git checkout <the-correct-branch> and then
git stash --restore
stash is like "shelf" in TFS??
Git basics
Branches make it easy to change the state of your code. checkout is the Git command that switches to another branch. the switch happens in-place on your local file system.
$> git checkout master
Also, making a new branch is also easy. To make a branch off of your current branch.
$> git branch <name-of-new-branch>
Branch is skill one
Branches make it easy to change the state of your code. checkout is the Git command that switches to another branch. the switch happens in-place on your local file system.
Also, making a new branch is also easy. To make a branch off of your current branch.
$> git branch -b <name-of-new-branch>
Branch is skill one
Merge some branch into the current branch.
First checkout the target branch. Then merge the source in with this command.
$> git checkout <target>
$> git merge <source>
The outcome of the merge,
One of three possibilities:
Merge is skill two
The merge fails due to the condition of the repo.
Usually this is uncommitted files.
To fix: either commit or stash the modified files.
Then try the merge again.
Merge is skill two
Best news all day!
This means that the merge was able to be competed automatically and no conflicts were found.
This is either great planning and teamwork, where Developers didn't need to work on the same files at the same time,
OR
maybe you are the only one working on this project, lonely yes, but easy to merge. :)
Merge is skill two
You have more work to do.
This means that the merge could not resolve all conflicts automatically. Yes you humans still have a purpose.
This means that Git found places in the code where both branches edited the same area of code and it cannot know how to resolve the two edits into one.
One or more files will need your attention.
Merge is skill two
example conflict text...
<<<<<<< Updated upstream
Groucho -- Well see right here, this it what is call a real bona fide contract.
=======
Groutcho -- Well see right here, this it what you call a real bonafide contract.
Here, you read it.
>>>>>>> Stashed changes
Merge is skill two
Use your branch and merge skills to execute these:
the most important point
(if nothing else is sticks)
Teams members should adopt a work pattern:
============ time to code ==============
checkout the correct branch for your task*
pull from origin (remote => local) pulling in others work.
pull again (a pull includes a merge)***
push your commits back up to the origin (local => remote)
====== take a rest, or get back to work =====
n8morse@gmail.com
@natemorse
github/nmorse
References
https://danielkummer.github.io/git-flow-cheatsheet/
https://www.atlassian.com/software/sourcetree
https://git-scm.com/downloads/guis
git-scm.com github.com