🤔 WTF is it?
Sylvain Fankhauser
Liip
May 2017
commit 66959dab20a37949828ac0502509656ac775f56d Author: Sylvain Fankhauser <sylvain.fankhauser@liip.ch> Date: Wed Nov 30 13:32:30 2016 +0100 Remove duplicate import
$ git rev-parse master
66959dab20a37949828ac0502509656ac775f56d
And contains the hash it points to
$ cat .git/refs/heads/master
66959dab20a37949828ac0502509656ac775f56d
eg. origin/master
Show remote commits that are not in local master branch. That's how pull requests work!
Show commits that are not common to both branches
Reset
# add file to the index
git add [-p] path/to/file
# remove file from the index
git reset [-p] path/to/file
# stash status of working directory, including index (-u means include untracked files)
git stash [-u]
# stash status of working directory and index and give the stash a name
git stash save "WIP try to fix this mess"
# show contents of stash (-p means show the diff)
git stash show [-p]
# show the list of existing stashes
git stash list [-p]
# apply stash and remove it
git stash pop [stash@{n}]
# add everything to the index
git add --all
# review changes
git diff --cached
# reset chunks if necessary
git reset -p path/to/file
# review changes
git diff --cached
# finally, commit with meaningful commit message (define a standard!)
git commit
To gitlab.liip.ch:tooyoo/tooyoo
! [rejected] HEAD -> sprint-3/mdb-21 (non-fast-forward)
error: failed to push some refs to 'git@gitlab.liip.ch:tooyoo/tooyoo'
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Integrate the remote changes (e.g.
hint: 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
As set by --set-upstream-to and recorded in .git/config
$ git push origin
$ git push origin master
$ git push origin master:newbranch # push master to newbranch
$ git push origin :newbranch # delete newbranch
mdb-72 / A---B---C---D---E origin/mdb-72
A---B---C---D---E origin/mdb-72 mdb-72
Merged branch only has common ancestors with current branch
git merge [--ff-only] origin/mdb-72
D---E mdb-72 / A---B---C \ origin/mdb-72
Current branch has ancestors absent from merged branch
git merge [--no-ff] origin/mdb-72
D---E---m mdb-72 / / A---B---C---/ \ origin/mdb-72
D---E mdb-72 / A---B---C \ origin/mdb-72
Replays non-common ancestors. This recreates commits!
git rebase origin/mdb-72
D'---E' mdb-72 / A---B---C \ origin/mdb-72
[merge]
ff = only
[pull]
ff = only
rebase = false
Then either use git pull or git fetch + git merge
until...
fatal: Not possible to fast-forward, aborting.
It's dangerous to go alone! Take this:
[alias]
incoming = "!git log ..@{u}"
outgoing = "!git log @{u}.."
inc = "!git incoming"
out = "!git outgoing"
Make sure you know what you're rebasing with git outgoing
If git outgoing --merges outputs anything, DO NOT rebase!
DO NOT REBASE!
DO. NOT. REBASE!
But it depends on your configuration
Works with merge and rebase
$> git reflog
83b206d HEAD@{0}: checkout: moving from sprint-4/mdb-20 to HEAD^
0e7b8ae HEAD@{1}: commit (amend): MDB-20 review fixes
051a6db HEAD@{2}: rebase finished: returning to refs/heads/sprint-4/mdb-20
051a6db HEAD@{3}: rebase: MDB-20 review fixes
83b206d HEAD@{4}: rebase: checkout refs/remotes/origin/sprint-4/mdb-20
753d540 HEAD@{5}: commit: MDB-20 review fixes
136b954 HEAD@{6}: commit (merge): Merge remote-tracking branch 'origin/sprint-4/master' into sprint-4/mdb-20
D---E mdb-72 / A---B---C \ origin/mdb-72
D---E
/
A---B---C
\
origin/mdb-72
mdb-72
git reset --hard origin/mdb-72
$ git show master:index.php
In case you screw up
add -p / reset -p / stash -p are your friends
Check for unrelated commits
You have tests, right?
It's okay to merge an in-progress feature branch in your feature branch
Fixtures anyone?
To make sure everyone benefits from them
To keep track of the merge
This will avoid problems when your local branch is not up-to-date
Your coworkers will thank you
Use multiple lines!
commit 10016ebf1603d0771b50b61720efd7fbd311b688
Author: Sylvain Fankhauser <sylvain.fankhauser@liip.ch>
Date: Mon Jan 9 15:50:33 2017 +0100
KOMPRA-230 fix empty graphs
If a competence layer doesn't have any children the outer bubble won't
appear. That's probably because this piece of code was copy-pasted from
StackOverflow and wasn't adapted.
Unless you're absolutely sure no one used them
They can help debugging if something goes wrong
Thank you!
master
sprint-4/master
sprint-4/mdb-82
sprint-4/mdb-82
sprint-4/mdb-83
sprint-4/mdb-82
sprint-4/master
support/mdb-404
master
sprint-4/master