Skip to content

Commit

Permalink
git info improved
Browse files Browse the repository at this point in the history
  • Loading branch information
cirosantilli committed Apr 13, 2013
1 parent b18f7b8 commit 55400a9
Show file tree
Hide file tree
Showing 18 changed files with 2,530 additions and 547 deletions.
103 changes: 41 additions & 62 deletions git → git/cheat.sh
Original file line number Diff line number Diff line change
@@ -1,18 +1,5 @@
#!/usr/bin/env bash

##sources

#<http://git-scm.com/book/en/Git-Branching-Basic-Branching-and-Merging>

#description of a production/dev/hotfix branch model:
#<http://nvie.com/posts/a-successful-git-branching-model/>

#update your cloned repo:
#<http://bassistance.de/2010/06/25/git-fu-updating-your-github-fork/>

#survey of git branching models:
#<http://stackoverflow.com/questions/2621610/what-git-branching-models-actually-work>

##config

#first of all steps: tell git who you are
Expand All @@ -30,12 +17,15 @@

git init

git remote add github "git@github.com:cirosantilli/python.git"
git remote add bitbucket "https://cirosantilli@bitbucket.org/cirosantilli/testrepo0.git"
##bare

#allows to push and pull current repo git@github.com:cirosantilli/python.git repo.
#starts a bare repo here:

#this repo gets an alias github. see #1 push for details
git init --bare

#it this contains directly the contents of the .git file.

#a repo must be bare if you want to push to it/pull from it

##clone

Expand All @@ -50,13 +40,19 @@

#see remote for what that means

##bare

#what github does on `fork`!

git clone --bare $R

##remote

#add remote sources to your git repo
#note that when you clone something, it alreay has a origin remote,
#so you usually only need this when doing the first push
#create aliases to a remote repo

#create a remote branch at github called github:
#when you clone something, it alreay has a origin remote.

#create an alias to a remote repo:

git remote add github https://github.com/cirosantilli/latex.git

Expand Down Expand Up @@ -116,11 +112,27 @@
# or leave it blank and cancel comit. action is taken after you save ans quit :wq

git commit -am 'commit message'

#same as above, but commits directly with message commit message

##ammend

#correct last commibt *before it was pushed*:

#does not create new commitmessage

#correct message only:

git commit -m 'new commit message'

#correct message and updates files:

git commit -m 'new commit message'

##push

#pushing is updating hte chages you made
#pushing is updating the chages you made

#it is better to add a remote

R=git@github.com:cirosantilli/bash.git
Expand All @@ -142,14 +154,17 @@
##fetch

#get changes from remote

#*does not change* current repo

#creates new remote/branch branches

git remote add upstream git@github.com:cirosantilli/test.git
git fetch upstream
git branch -r

#origin/master

#upstream/master

##pull
Expand Down Expand Up @@ -247,9 +262,9 @@
#all differences between current state and last commit
#no need to have added the files

git checkout $hash #go back to given Hash and KEEP changes. new commits will start branches
git checkout $hash #go back to given Hash and KEEP changes. new commits will start branches
git checkout master #go back to last commit and lose uncommited changes on all files
git checkout $hash #go back to hash (beginning of hash). lose uncommited
git checkout $hash #go back to hash (beginning of hash). lose uncommited
git checkout $hash -- $file1 $file2

#revert only those files
Expand All @@ -267,7 +282,7 @@

#if you are sure you are the only one, push --force will do

##branch and merge
##branch

#branching is creating a separate path of developement

Expand Down Expand Up @@ -295,50 +310,14 @@

git branch -d "$B"

#merge master with another branch :

git checkout master
git merge "$B"

#if auto merge is fine:

#master goes to new node created after merge

#else

git status

#shows what was unmerged

#needs merge
##merge

#files get modified to contain trash merge markers

#open with a merging tool:

git mergetool

##remove file completelly from repo

#for example:
#sensitive data
UNAME=cirosantilli
REPONAME=python
REPOURL=https://github.com/$UNAME/$REPONAME.git
RMFILE=

git filter-branch --index-filter "git rm --cached --ignore-unmatch \"$RMFILE\"" --prune-empty -- --all
git push github master --force

#remove from local dir

rm -rf .git/refs/original/
git reflog expire --expire=now --all
git gc --prune=now
git gc --aggressive --prune=now

#MAIL ALL COLABORATORS AN TELL THEM TO git rebase

##submodule

#use outside repos inside you main repo,
Expand Down
43 changes: 43 additions & 0 deletions git/makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#compiles all .md files in current directory into pdf and html.

#can mkdir and output that dir.

override CCC ?= pandoc
override FLAGS ?= -s --toc --mathml -N #flags that apply to all kinds of output (html, pdf, etc)
override ID ?=
override IN_EXT ?= .md
override OUT_DIR ?= _out/
override RUN_NOEXT ?= a #basename without extension of file to view (with firefox, okular, etc.)

SRCS := $(wildcard *$(IN_EXT))
OUTEXT := .html
OUT_HTML := $(patsubst %$(IN_EXT),$(OUT_DIR)%$(OUTEXT),$(SRCS))

OUTEXT := .pdf
OUT_PDF = $(patsubst %$(IN_EXT),$(OUT_DIR)%$(OUTEXT),$(SRCS))

.PHONY: all mkdir html pdf firefox okular clean

all: html pdf

mkdir:
mkdir -p $(OUT_DIR)

html: mkdir $(OUT_HTML)

pdf: mkdir $(OUT_PDF)

firefox:
firefox "$(OUT_DIR)$(RUN_NOEXT).html$(ID)"

okular:
nohup okular --unique "$(OUT_DIR)$(RUN_NOEXT).pdf" >/dev/null &

$(OUT_DIR)%.html: %$(IN_EXT)
$(CCC) $(FLAGS) -o $@ $<

$(OUT_DIR)%.pdf: %$(IN_EXT)
$(CCC) $(FLAGS) -o $@ $<

clean:
rm -r "$(OUT_DIR)"
Loading

0 comments on commit 55400a9

Please sign in to comment.