git help
Also, the Git Comminuty Book is very good.
git config --global user.name "My Name"
git config --global user.email "me@example.com"
Creating a new repository from an existing project
cd myproject
git init
git add .
git commit -m "Initial import of existing source."
Creating a new remote git repository
Setup a bare repository on the server.
local$ ssh example.com
remote$ mkdir /home/me/git/myproject
remote$ git --bare init
Link remote repository to your local repository.
local$ cd /home/me/git
local$ git remote add origin ssh://example.com/home/me/git/myproject
local$ git push origin master
Committing changes to a local repository
After working on existing files or adding new files, add them to the staging areas in preparation for a commit:
git add file1 file2 file3
Review a summary of what will happen on commit:
git status
If git status looks good, then:
git commit
Alternately, this will automatically commit any changed files (but not new files):
git commit -a
Using a local repository with remote repository
Push local changes to remote repository:
cd myproject
git push ssh://example.com/home/me/git/myproject master
Update your existing local repository with any changes from remote:
git pull ssh://paulgorman.org/home/paulgorman/git/blelo master
Grab a fresh local copy from remote server:
git clone ssh://example.com/home/me/git/myproject
Branching and merging
Show the branch on which you're currently operating:
git branch
Create a new branch:
git branch mynewbranch
Switch the branch on which you're currently operating:
git checkout anotherbranch
If you're in anotherbranch, and want to merge your changes from mynewbranch:
git merge mynewbranch
If there are no conflits, it just works. If there are conflicts, you can see them with:
git diff
After you manually resolve any conflicts:
git commit
Links
- Git Community Book
- Git for the lazy
- Setting up a new remote git repository
- Everyday GIT With 20 Commands Or So
- gittutorial(7) man page
© Paul Gorman