-- FernandoHaraldBarreiroMegino - 2015-01-29

Using Git

Reference: Version Control with Git (2nd Edition covers Github), John Loeliger & Matthew McCullough, O'Reilly

Configuration files


(In decreasing priority!)
.git/config: repository specific config
~/.gitconfig: user specific config
/etc/gitconfig: system config

Configuring github user

Fernandos-MBP-2:~ fbarreir$ git config --global user.name "Fernando Barreiro Megino"
Fernandos-MBP-2:~ fbarreir$ git config --global user.email "fh.barreiro@gmail.com"
Fernandos-MBP-2:~ fbarreir$ git credential-osxkeychain
usage: git credential-osxkeychain <get|store|erase>   #MEANS IT’S INSTALLED!
Fernandos-MBP-2:~ fbarreir$ git config --global credential.helper osxkeychain
Fernandos-MBP-2:~ fbarreir$ git config -l
user.name=Fernando Barreiro Megino
user.email=fh.barreiro@gmail.com
core.editor=emacs
credential.helper=osxkeychain
The next time you clone an HTTPS URL that requires a password, you'll be prompted for your username and password, and to grant access to the OSX keychain. After you've done this, the username and password are stored in your keychain and you won't be required to type them in to Git again.

Setting up aliases

git config --global alias.show-graph \
'log --graph --abbrev-commit --pretty=oneline'

Query the state of an index

git status
git ls-files
git ls-files --stage

File statuses


Tracked
Untracked
Ignored: Specified in .gitignore

Inspecting the history of commits

gitk
git bisect
git blame -L 35, init/version.c

Branches


Create branches
git branch prs/pr-1138 #Create branch from HEAD
git branch prs/pr-1138 rel-2.3 #Create branch from tag rel-2.3
git branch prs/pr-1138 db7de5feebef8bcd18c5356cb47c337236b50c13 #Create branch from commit

Inspect branches

git branch
git show-branch
git show-branch bug/pr-1 bug/pr-2

Change your working directory to a branch

git checkout bug/pr-1
git checkout -b bug/pr-3 #Create a new branch and switch to it

Merges

The git merge operation is context sensitive. Your current branch is always the target branch, and the other branch or branches are merged into the current branch.

git merge alternate
git log --graph --pretty=oneline --abbrev-commit

Working with remote repositories

git fetch: Retrieves objects and their related metadata from a remote repository.
git pull: Like git fetch, but also merges changes into a corresponding local branch.
git push: Transfers objects and their related metadata to a remote repository.
git ls-remote: Shows a list of references held by a given remote (on an upstream server). This command indirectly answers the question “Is an update available?”

Distutils

Reference: https://docs.python.org/2/distutils/index.html

MANIFEST.in files

Command Description
include pat1 pat2 ... include all files matching any of the listed patterns
exclude pat1 pat2 ... exclude all files matching any of the listed patterns
recursive-include dir pat1 pat2 ... include all files under dir matching any of the listed patterns
recursive-exclude dir pat1 pat2 ... exclude all files under dir matching any of the listed patterns
global-include pat1 pat2 ... include all files anywhere in the source tree matching — & any of the listed patterns
global-exclude pat1 pat2 ... exclude all files anywhere in the source tree matching — & any of the listed patterns
prune dir exclude all files under dir
graft dir include all files under dir

Python

iPython

Reference: Python for data analysis, Wes McKinney

Commands

Command Description
%quickref Display the IPython Quick Reference Card
%magic Display detailed documentation for all of the available magic commands
%debug Enter the interactive debugger at the bottom of the last exception traceback
%hist Print command input (and optionally output) history
%pdb Automatically enter debugger after any exception
%paste Execute pre-formatted Python code from clipboard
%cpaste Open a special prompt for manually pasting Python code to be executed
%reset Delete all variables / names defined in interactive namespace
%page OBJECT Pretty print the object and display it through a pager
%run script.py Run a Python script inside IPython
%prun statement Execute statement with cProfile and report the profiler output
%time statement Report the execution time of single statement
%timeit statement Run a statement multiple times to compute an emsemble average execution time. Useful for timing code with very short execution time
%who, %who_ls, %whos Display variables defined in interactive namespace, with varying levels of information / verbosity
%xdel variable Delete a variable and attempt to clear any references to the object in the IPython internals

Interacting with the OS

Command Description
cmd Execute cmd in the system shell
output = cmd args Run cmd and store the stdout in output
%alias alias_name cmd Define an alias for a system (shell) command
%bookmark Utilize IPython’s directory bookmarking system
%cd directory Change system working directory to passed directory
%pwd Return the current system working directory
%pushd directory Place current directory on stack and change to target directory
%popd Change to directory popped off the top of the stack
%dirs Return a list containing the current directory stack
%dhist Print the history of visited directories
%env Return the system environment variables as a dict
Edit | Attach | Watch | Print version | History: r7 < r6 < r5 < r4 < r3 | Backlinks | Raw View | Raw edit | More topic actions...
Topic revision: r4 - 2015-02-07 - FernandoHaraldBarreiroMegino
 
    • Cern Search Icon Cern Search
    • TWiki Search Icon TWiki Search
    • Google Search Icon Google Search

    Main All webs login

This site is powered by the TWiki collaboration platform Powered by PerlCopyright &© 2008-2021 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
or Ideas, requests, problems regarding TWiki? use Discourse or Send feedback