GitFlow and Version Control with Git

Consider a version format of X.Y.Z (Major.Minor.Patch). Bug fixes not affecting the API increment the patch version, backwards compatible API additions/changes increment the minor version, and backwards incompatible API changes increment the major version. – semver.org

 

GitFlow – https://datasift.github.io/gitflow/IntroducingGitFlow.html

Screen Shot 2019-04-09 at 1.33.20 PM.png

 

 

A successful Git branching model: https://nvie.com/posts/a-successful-git-branching-model/

https://www.learnenough.com/git-tutorial

git_status_sequence.png

Command Description Example
git help Get help on a command $ git help push
git config Configure Git $ git config --global …
source <file> Activate Bash changes $ source ~/.bash_profile
mkdir -p Make intermediate directories as necessary $ mkdir -p repos/website
git status Show the status of the repository $ git status
touch <name> Create empty file $ touch foo
git add -A Add all files or directories to staging area $ git add -A
git add <name> Add given file or directory to staging area $ git add foo
git commit -m Commit staged changes with a message $ git commit -m "Add thing"
git commit -am Stage and commit all changes with a message $ git commit -am "Add thing"
git diff Show diffs between commits, branches, etc. $ git diff
git commit --amend Amend the last commit $ git commit --amend
git show <SHA> Show diff vs. the SHA $ git show fb738e…
Command Description Example
git remote add Add remote repo $ git remote add origin 

$ git remote add origin https://github.com/<username>/<reponame>.git

git push -u <loc> <br> Push to branch to remote $ git push -u origin master
git push Push to default remote $ git push
git remote add origin git@github.com:User/UserRepo.git

is used to a add a new remote

git remote set-url origin git@github.com:User/UserRepo.git

is used to change the url of an existing remote repository

git push -u origin master

will push your code to the master branch of the remote repository defined with origin and -u let you point your current local branch to the remote master branch.

Command Description Example
.gitignore Tell Git which things to ignore $ echo .DS_store >> .gitignore
git checkout <br> Check out a branch $ git checkout master
git checkout -b <br> Check out & create a branch $ git checkout -b about-page
git branch Display local branches $ git branch
git merge <br> Merge in a branch $ git merge about-page
git rebase Do something possibly weird & confusing See Figure 2 and Figure 3
git branch -d <br> Delete local branch (if merged) $ git branch -d about-page
git branch -D <br> Delete local branch (even if unmerged) (dangerous) $ git branch -D other-branch
git checkout -f Force checkout, discarding changes (dangerous) $ git add -A && git checkout -f
Command Description Example
git clone <URL> Copy repo (incl. full history) to local disk $ git clone https://ex.co/repo.git
git pull Pull in changes from remote repository $ git pull
git branch -a List all branches $ git branch -a
git checkout <br> Check out remote branch and configure for push $ git checkout fix-trademark
git push origin --delete <br> Delete remote branch $ git push origin --delete fix-trademark