GIT ADVANCED

What is a remote?

(managing the distance)

Me

Initial App

(locally)

(upstream)

Forked App

(origin)

push

pull
request

pull

Collegue 1

Collegue 2

Git Flow Example

Distant Repo are Remotes

  • The original fork is UPSTREAM
  • Your forked repo is ORIGIN
  • Your collegues forked are named as you like

Have a look at Sébastien's Saunier article

to understand Le Wagon's workflow

Adding Remotes

git remote -v
=> list all remotes

git remote add pickaname colleguerepo
=> download collegue repo

git checkout -B pickaname remote/remotebranch
=> retrieve a specific branch of a collegue

And Heroku ?

git push heroku branchname:master

WHAT I want to do

on WHICH repo

WHICH local branch I want to push

ON heroku branch master

Cool Git tricks

Git add -p

One modification at a time

git add -p

Git alias

Git like nobody understands

git config --global alias.SHORTCUT_NAME TERM_REPLACED

> git config --global alias.co checkout
> git config --global alias.ci commit

Stash

(I'll be back)

git stash
=> put modifications aside

git stash pop
=> retrieve stashed elements

git stash list
=> list all your stashed elements

git stash apply stash@{1}
=> apply that particular stash

git stash clear
=> delete all your stashed elements

Cherry-pick

(Just that one, please)

git cherry-pick d42c389f
=> just get the commit you need

Reset

(Come back)

git reset --hard d42c389f
=> let's go back to that one

git reflogs is very useful to cancel
a reset --hard :
It lists all your git command history 
and you can comeback to a previous
state easily

Amend

(Oups !)

git commit --amend
=> apply last staged changes to previous commit

Can also be used to rename a commit

Rebase

(Be clean)

git rebase -i HEAD~2

Great Git Tools

TIG

Have a look here

GITG

have a look here

Git Cheat Sheets

Gitlab Cheat Sheet

Online ressources

This is the end !

Please, feel free to share your git tips and tricks with a comment

Made with Slides.com