Commit:
git add FILE git commit -m 'DESCRIPTION'
Tag:
git tag TAGNAME commit-hash
Create New Branch:
git branch XXX
Switch Branch:
git checkout XXX
Delete uncommitted changes:
git reset --hard
DO NOT EDIT ON SERVER
1 - Create repo on server, tweak settings
$ ssh server $ cd X $ git init . $ git config receive.denyCurrentBranch ignore $ vim .git/hooks/post-receive
#!/bin/sh # Update the working tree after changes have been pushed here cd .. env -i git reset --hard
$ chmod +x .git/hooks/post-receive
2 - Create remote on server
$ git remote add live ssh://user@example.com/home/example/public_html
3 - Push to server
$ git push live origin
Sources:
For adding remotes, etc – Don't forget to point out the protocol, i.e.
ssh://git@li345-114.members.linode.com/var/git/XXX
| Client A | Client B | Server | Comment |
|---|---|---|---|
| adduser –home /var/git git | |||
| chown git:git /var/git | |||
| su - git | |||
| cd /var/git | |||
| mkdir proj | |||
| git init –bare . | Init bare repository | ||
| cd /proj | |||
| git init . | |||
| touch README | |||
| git add README | |||
| git commit -m 'first' | |||
| git remote add origin git@server/var/git/proj | Adds origin remote | ||
| git push origin master | Push master to origin | ||
| git clone git@server:/var/git/proj | Clone origin |
| Client A | Client B | Comment |
|---|---|---|
| git add X | ||
| git commit -m 'Y' | ||
| git push origin master | ||
| git pull |
| Client A | Client B | Comment |
|---|---|---|
| git checkout -b xyz | Create branch xyz | |
| git add X | ||
| git commit -m 'Y' | ||
| git push origin xyz | Push branch xyz to origin | |
| git pull origin xyz | Pull branch xyz from origin | |
| git checkout xyz | Checkout branch xyz |
NB: git pull does git fetch, then git merge