Git - JasonLocklin/jasonlocklin.github.com GitHub Wiki
layout: page title: "Git Notes" description: "Collection of notes about using git"
{% include JB/setup %}
Quick reference notes for using git.
Basic Command Usage
Begin versioning a directory
git init
Create an empty git remote
git init --bare
Clone from a remote
git clone /filelocation
git clone ssh://URL
git clone https://URL
Create a new branch or tag
git checkout -b newbranchname
git tag newtagname
Interact with files
git add filename
git add -p filename #only add some of the changes
git rm filename
git mv filename
git status
git commit filename -m"Description of current state"
Interacting with remote
git pull origin master
git pull origin otherbranch
git push origin
git push origin branchname
Branches
git branch branchname #create branchname
git checkout branchname #switch to branchname
git merge branchname #bring in commits from branchname
git rebase #cleaner merge if commits havn't been pushed
Encrypted remote (https://github.com/blake2-ppc/git-remote-gcrypt)
git remote add cryptremote gcrypt::sftp://example.com:repo
git push cryptremote master
Odd Commands
Pull a file from another branch
git checkout branch filename
Amend previous commit
git commit --amend
Fix up commit history (if it has not been pushed)
git rebase -i <parent branch or commit>
Push all branches and tags to remote (careful if you have development branches or any thing else you don't want published)
git push origin --mirror
Cleaning dir of untracked files
git clean -n #dry run check what get's deleted
git clean -f #delete them
git clean -f -X #just ignored files
git clean -f -x #ignored & non-ignored files
git clean -f -d #also directories
Add a new remote to an existing repository. First create bare repository on remote machine. Then add the remote.
git remote add origin [email protected]:JasonLocklin/reponame
git push origin
Migrating old SVN projects to Git:
Note, use correct URLs and usernames, etc.
Mkdir projectname
svn2git "svn+ssh://[email protected]/home/svn/jay/projectname" --verbose --no-minimize-url --rootistrunk
note: if running into errors, delete .git directory.
Then, push the repro to host
git init --bare
git remote add --track master origin ssh://lab/home/jay/SaccadicAdaptation
git remote add --mirror=push backup /home/jay/dbox/SaccadicAdaptation/
Resources:
- [Keeping Commit Histories Clean](A theory of neural dimensionality and dynamics)