Git: Quick Commands, init, checkout, branch, remote add, push, pull,…
April 16th, 2009 by jeremychoneLocal repository
Create a repository:
> cd projectA > git init
Add all the files
> git add .
Commit
> git commit
Create a public repository
Create empty bare repository (on server http://myserver.com/)
> cd /var/www/html/projectAPub > git --bare init > git --bare update-server-info
Make sure the hooks/post-update is enabled (see doc)
> cd ./hooks > chmod +x post-update
Push to public repository
Add the remote
> cd projectA > git remote add origin ssh://username@myserver.com/var/www/html/projectAPub
Push to the public repository (origin)
> git push origin master
Get repository from Public repository
> git clone http://myserver.com/projectAPub projectA
This will create a “remote” with the default name “origin”
Get remote branch
Show remote branch(es)
> git remote show origin
Track a remote branch (fetch to make sure you have the latest remote definition)
> git fetch > git branch --track other_branch origin/other_branch