Showing posts with label svn. Show all posts
Showing posts with label svn. Show all posts

Thursday, June 02, 2011

Git INFO Common Commands

Configure Git client options:
# show config options
git config --list # show all
git config --global --list # show only global
git config --local --list # show only local

# --global option impacts options at a global level
# --local option impacts options at a local level (.git/config)

# set username/email associated with client
git config --global user.email "joe@example.com"
git config --global user.name "Joe Jaz"

# add color syntax highlighting
git config --global color.status auto
git config --global color.branch auto

# set default pager and editor
git config --global core.editor vim # or set the GIT_EDITOR environment variable
git config --global core.pager less # or set the GIT_PAGER environment variable

# display an option value
git config group.value
git config user.name

Start a new repository and import:
# In the root folder to add to version control:
git init
git init --bare  # creates a new repository (with no working copy)
git add . # add everything in directory to repo
git commit -m 'initial commit'

Making commits:
# commit specific files
git commit file1 file2 -m 'comment'

# commit all 'added' files
git commit -a -m 'comment'

# change a commit message
git commit --amend -m 'New Message'

Create new repository by cloning existing one:
git clone --bare . path_or_url_to_git_dir.git

Setting the remote repository (to push and pull from):
git remote add short_name path_or_url_to_git_dir.git
git remote add origin git://github.com/imagescape/iscape-authlog.git

Show remote repositories available:
git remote
git remote -v # show the url
git remote show origin  # show detail information about origin

Remove a remote repository: 
git remove repo_name

Rename a remote repository: 
git rename old_repo_name new_repo_name

Push and Pull from remote repository:
git push origin # push recent commits to remote repository called "origin"
git pull origin # pull updates from origin

Revert changes in working copy:
git clean -n
git clean --dry-run

Show file differences:
git diff   # show differences between working copy and any files staged for commit
git diff --staged   # compares staged changes with last commit
git diff --cached  # same as above for git older than 1.6.1

git difftool -t [meld|kdiff3|vimdiff|etc.] [diff criteria]
git difftool -t meld --staged
git difftool --tool=meld --staged
git difftool origin/master  --dir-diff # use difftool to diff entire dir tree

git diff -U999999999 master.. -- file.txt # shows the full file.txt, with diff markup, in the master/branch diff results

git diff --name-status brancha..branchb # shows list of changed files

Show File/s History:
git log filename # Show single file versions

# Show number of lines changed in file/s
git log -stat filename # single file
git log -stat # multiple files

# show log summaries on one line
git log --pretty=oneline # Pre-defined format
git log --pretty=format:"%h - %cD (%an) %s" # custom format (see below)
git log --pretty=format:"%h %s" --graph
git log --graph --full-history --all --color \
           --pretty=format:"%x1b[31m%h%x09%x1b[32m%d%x1b[0m%x20%s"
    Pre-Defined Pretty formats:
    oneline
    short
    medium
    full
    fuller
    email
    raw
    format:string # where string is

        Format Strings
        %H: commit hash
        %h: abbreviated commit hash
        %T: tree hash
        %t: abbreviated tree hash
        %P: parent hashes
        %p: abbreviated parent hashes
        %an: author name
        %aN: author name (respecting .mailmap, see git-shortlog(1) or git-blame(1))
        %ae: author email
        %aE: author email (respecting .mailmap, see git-shortlog(1) or git-blame(1))
        %ad: author date (format respects --date= option)
        %aD: author date, RFC2822 style
        %ar: author date, relative
        %at: author date, UNIX timestamp
        %ai: author date, ISO 8601 format
        %cn: committer name
        %cN: committer name (respecting .mailmap, see git-shortlog(1) or git-blame(1))
        %ce: committer email
        %cE: committer email (respecting .mailmap, see git-shortlog(1) or git-blame(1))
        %cd: committer date
        %cD: committer date, RFC2822 style
        %cr: committer date, relative
        %ct: committer date, UNIX timestamp
        %ci: committer date, ISO 8601 format
        %d: ref names, like the --decorate option of git-log(1)
        %e: encoding
        %s: subject
        %f: sanitized subject line, suitable for a filename
        %b: body
        %B: raw body (unwrapped subject and body)
        %N: commit notes
        %gD: reflog selector, e.g., refs/stash@{1}
        %gd: shortened reflog selector, e.g., stash@{1}
        %gs: reflog subject
        %Cred: switch color to red
        %Cgreen: switch color to green
        %Cblue: switch color to blue
        %Creset: reset color
        %C(…): color specification, as described in color.branch.* config option
        %m: left, right or boundary mark
        %n: newline
        %%: a raw %
        %x00: print a byte from a hex code
        %w([[,[,]]]): switch line wrapping, like the -w option of git-shortlog(1).

Show git branches available:
git branch

Show all branches including remote branches:
git branch -a

Create new branch:
git branch new_branch

Change branches:
git checkout new_branch

Delete branch:
git branch -d new_branch # delete only if all changes are merged
git branch -D new_branch  # delete even if there are unmerged changes

Merge branch into current copy:
git merge --no-ff branch_to_merge_in

Resolve a Merge:
1) Edit file to resolve
2) git add conflict_file
3) git commit

Using Mergetool
git mergetool
git mergetool --tool=meld
git mergetool -t meld

Abort a merge conflict before committing:
git merge --abort

Undo a Merge:  # restores state to pre-merge
git reset --heard HEAD

Undo a local commit: 
git reset --soft HEAD^

Find the commit where two branches diverge:
git merge-base branch1 branch2

    http://stackoverflow.com/questions/1549146/find-common-ancestor-of-two-branches

Find what branches were merged into a given branch:
git branch --merged master  # local branches only
git branch -a --merged master   # local and remote branches

Find what branches were NOT merged into a given branch:
git branch --no-merged master  # local branches only
git branch -a --no-merged master   # local and remote branches

Find what branches are merged into develop, but not master:
comm -12 <(sort <(git branch -a --no-merged origin/master)) <(sort <(git branch -a --merged origin/develop))

    https://stackoverflow.com/questions/8071079/git-list-branches-merged-into-a-branch-but-not-into-another

Copy all branches from origin to new_remote: 
git push new_remote refs/remotes/origin/*:refs/heads/*

Get number of commits per author
apt-get install git-extras

Tuesday, May 03, 2011

SVN List Codes

Codes Displayed when doing an "svn stat"
U = Working file was updated
G = Changes on the repository were automatically merged into the working copy
M = Working Copy is modified
C = This file conflicts with the version in the repo
? = This file is not under version control
! = This file is under version control but is missing or incomplete
A = This file will be added to version control after commit
A+ = This file will be moved after commit
D = This file will be deleted after commit
I = This item is being ignored (due to the svn:ignore porperty)
L = This file is locked
X =  Item is unversioned, but used by an externals definition
~ = Messed up item (file when it should be dir). resolve by moving and doing "svn up"

http://knaddison.com/technology/svn-status-code-cheat-sheet

Thursday, April 21, 2011

Quick Setup Instructions for SVN Compile and Local Install

Steps to make a custom build of SVN and place it in non-system directory.

Make a place to store the new copy:
mkdir -p /home/myuser/customsvn/src/
cd /home/myuser/customsvn/src/

Download from Apache Subversion; place in local install src directory:
ls -la /home/myuser/customsvn/src/
subversion-1.6.xx.tar.bz2
subversion-deps-1.6.xx.tar.bz2

Untar subversion then subversion-deps:
tar -jxvf subversion-1.6.xx.tar.bz2
tar -jxvf subversion-deps-1.6.xx.tar.bz2

Configure Command (Configure without Apache stuff):
./configure --prefix=/home/myuser/customsvn/bin/svn/ --with-apxs=no --disable-mod-activation --with-serf=no --with-berkeley-db=no  | tee configure.jjj.log
make | tee make.jjj.log
make install | tee make_install.jjj.log

Tuesday, April 19, 2011

SVN Merging For Version 1.4-

Merging for svn 1.4- is a bit different than for newer versions.  
This is what I have found that works for merging a trunk to a branch:
svn merge \
  svn+ssh://svn.example.com/repo/myproject/branches/newbranch@HEAD \
  svn+ssh://svn.example.com/repo/myproject/trunk@HEAD \
  /sites/myproject/src/myproject-workingcopy


*NOTE: seems weird that the trunk is the argument after the branch, but my trunk changes weren't being merged in when I did it the other way.

It seems that with svn version pre 1.4, you must specify the version where your branch was last copied or merged from.  If your branch was created at version 234, then the following command would merge it. 
svn merge --dry-run \
  svn+ssh://svn.example.com/export/myproject/branches/newbranchh@234 \
  svn+ssh://svn.example.com/export/myproject/trunk/@HEAD .


http://www.svnforum.org/threads/38394-1.4-merge

Sunday, February 01, 2009

svn+ssh on alternate port

Setup the config
# Add the following lines to ~/.subversion/config
# must be put in the [tunnels] section of the config file
sshnew=ssh -l user -p 2222

Execute the svn:
svn co svn+sshnew://servername.com/path/to/repository/

Wednesday, August 22, 2007

Subversion

Setting up a repository:
svnadmin create /usr/local/svn/newrepos

Import files into repository:

svn import /import/dir file:///usr/local/svn/newrepos/projectname -m "comment"

List files in a repository tree:

svn list file:///usr/local/svn/newrepos/projectname
svn ls #while in sandbox
svn ls -v # verbose

Checkout a directory:

svn checkout "http://host:port/path"
svn co http://host:port/path
svn checkout file:///path/to/repos
svn checkout file:///localhost/path/to/repos
svn checkout svn+ssh://host/path/to/repos

Check a specific revision:
svn checkout -r revision_num
svn checkout -r {2006-02-17}
svn checkout -r {"2006-02-17 15:30"}

Checkin a file:
svn commit filename.txt -m "some comment here"

Update working copy with committed changes from other users:
svn update

Manage local copy (sandbox):
svn add filename
svn delete filename
svn move file1 file2
svn copy file1 file2
svn mkdir dirname

View files changed since last commit:
svn stat
svn stat filename
svn status -v # verbose view of all files in sandbox
svn status -v -u # contacts the repository to show more info

View changes since last commit:
svn diff # show diffs within files

Revert a file (working copy):
svn revert file


Restore a previously committed file back to working copy:
svn merge -r curr_version:prev_version working_file.txt

Show revision history:
svn log
svn log -r 5:19 # shows revisions 5 through 19
svn log -r 9 # shows revision 9
svn log filename # show revisions on a given file
svn log -r {2006-11-20}:{2006-11-22} # show versions between two dates
svn log --verbose # show all files in all revisions
svn log --verbose | grep "/path/to/file/" -B10 # grep history and show last 10 lines

Show file info:
svn info filename

Backup a repository:
svnadmin dump
/path/to/repository > dumpfile

Restore a repository:

svnadmin load
/path/to/repository/ < dumpfile.dump

Export a repository without all the metadata:
svn export file:///path/to/repository export_dir

Ignore files in the svn working copy:
create a file in home directory called .svnignore 
While in working copy, run command
svn -R propset svn:ignore -F /path/to/home/.svnignore .


http://pandemoniumillusion.wordpress.com/2008/05/07/ignore-pyc-files-in-subversion/

http://svnbook.red-bean.com/en/1.0/re10.html
http://svnbook.red-bean.com/en/1.0/re36.html
http://aralbalkan.com/1381
http://svnbook.red-bean.com/en/1.1/svn-book.html#svn-ch-3-sect-6.2.2