My GitHub
http://github.com/javacom
Showing posts with label git. Show all posts
Showing posts with label git. Show all posts
Monday, April 18, 2011
Sunday, November 22, 2009
How to create local and remote ssh git repo in Mac OS X
(1) Install git for Mac OS X
(2) Create localrepo in local harddisk / SMB Share (assume already init as a repository)
init as a git repository
git mkdir -p /Volumes/Data/GIT
git clone --bare ~/myproject /Volumes/Data/GIT/myproject.git
touch /Volumes/Data/GIT/myproject.git/git-daemon-export-ok
push to localrepo
(3) Suppose you have a project in ~/myproject
and the remote ssh server login is user@xxx.xxx.xxx.xxx
both client and server have git installed
(4) Create sshrepo in remote server over ssh
check the location of remote git binary and the remote ssh login shell
mine is /usr/local/bin/git-upload-pack
if the remote login shell does not include path of git, create ~/.bashrc in your remote ssh login shell
push to sshrepo
Test git clone
or
How to Branch
How to checkout a previous commit
How to push to github
mkdir ~/src
cd ~/src/
curl -O http://kernel.org/pub/software/scm/git/git-1.6.5.3.tar.bz2
tar -xjvf git-1.6.5.3.tar.bz2
cd git-1.6.5.3
./configure --prefix=/usr/local
make
sudo make install
git --version(2) Create localrepo in local harddisk / SMB Share (assume already init as a repository)
init as a git repository
cd ~/myproject
git init
git add .
git rm -r --cache build # ignore the build directory for iPhone project
git commit -m 'Initial commit'
git mkdir -p ~/git
git clone --bare ~/myproject ~/git/myproject.git
touch ~/git/myproject.git/git-daemon-export-okgit mkdir -p /Volumes/Data/GIT
git clone --bare ~/myproject /Volumes/Data/GIT/myproject.git
touch /Volumes/Data/GIT/myproject.git/git-daemon-export-ok
push to localrepo
cd ~/myproject
git remote add localrepo ~/git/myproject.git
git push localrepo master
git log(3) Suppose you have a project in ~/myproject
and the remote ssh server login is user@xxx.xxx.xxx.xxx
both client and server have git installed
(4) Create sshrepo in remote server over ssh
ssh user@xxx.xxx.xxx.xxx "mkdir -p /Volumes/HD/git/myproject.git; cd /Volumes/HD/git/myproject.git; git --bare init; touch git-daemon-export-ok"check the location of remote git binary and the remote ssh login shell
ssh user@xxx.xxx.xxx.xxx "which git-upload-pack"
ssh user@xxx.xxx.xxx.xxx "echo \$PATH"mine is /usr/local/bin/git-upload-pack
if the remote login shell does not include path of git, create ~/.bashrc in your remote ssh login shell
ssh user@xxx.xxx.xxx.xxx "echo 'export PATH=\${PATH}:/usr/local/bin' > ~/.bashrc"push to sshrepo
cd ~/myproject
git remote add sshrepo ssh://user@xxx.xxx.xxx.xxx/Volumes/HD/git/myproject.git
git push sshrepo master
git logTest git clone
cd ~
git clone ~/git/myproject.git workinglocal
cd workinglocal
git logor
cd ~
git clone ssh://user@xxx.xxx.xxx.xxx/Volumes/HD/git/myproject.git workingremote
cd workingremote
git logHow to Branch
git branch -r # show branch in repo
git checkout -b todo origin/to-do-branch # checkout a new branch
git checkout master # checkout the master branch
git checkout localrepo/master # checkout the master branch in localrepo
git checkout sshrepo/master # checkout the master branch in sshrepo
git branch next # create new branch
git add .
git commit -m 'commit nextbranch'
git push localrepo next
git branch -b cygwin
git branch -r
git add *
git commit -m 'commit cygwin branch'
git push origin cygwinHow to checkout a previous commit
git log # show log of previous commit
git log --format=oneline # show log of previous commit log hex digit
git checkout 838fbf2e9b050d2350694235bbf5e9a11fa7acea # commit log hexdigit
git checkout 838fbf2e9b050d2350694235bbf5e9a11fa7acea -- file1/to/restore file2/to/restore # checkout files to restoreHow to push to github
git config --global user.name "javacom"
git config --global user.email "javacomhk@yahoo.com"
git remote rm origin
git remote add origin git@github.com:javacom/toolchain4.git
git push origin master
Subscribe to:
Posts (Atom)