Git
Git [1], is a distributed revision control and source code management (SCM) system with an emphasis on speed. Initially designed and developed by Linus Torvalds for Linux kernel development, Git has since been adopted by many other projects. Every Git working directory is a full-fledged repository with complete history and full revision tracking capabilities, not dependent on network access or a central server.
Setup
To setup git [2]
Username
First you need to tell git your name, so that it can properly label the commits you make.
# Sets the default name for git to use when you commit. $ git config --global user.name "harm"
Git saves your email address into the commits you make. We use the email address to associate your commits with your GitHub account.
# Sets the default email account for git when you commit $ git config --global user.email "h.frielink@<you-server-name>"
Cheat Sheet
Always handy are Cheat Sheets [3].
Create & Clone | Add & Remove | ||
---|---|---|---|
Create new repo | git init | Add changes to INDEX | git add <filename> |
Clone local repo | git clone /path | Add all changes to INDEX | git add * |
Clone remote repo | git clone username@host:/path/to/repo | Remove / Delete | git rm <filename> |
Commit & Synchronize | Branches | ||
---|---|---|---|
Commit changes | git commit -m "Message" | Create new branch | git checkout -b <branch> i.e.: git checkout feature-x |
Push changes to remote repo | git push origin master | Switch to master branch | git checkout master |
Connect local repo to remote repo | git remote add origin <server> | Delete branch | git branch -d <branch> |
Update local repo with remote changes | git pull | push branch to remote repo | git push origin <branch> |
Merge | Tagging | ||
---|---|---|---|
Merge changes from another branch | git merge <branch> | Create tag | git tag <tag> <commit-ID> |
View changes between 2 branches | git diff <src-branch> <trg-branch> | Get commit IDs | git log |
See also
Reference
- ↑ Wikipedia Git-description, Git Software
- ↑ help-github, Setup.
- ↑ Roger Dudler, Sheet Cheat