- To clone a repo: move to the desired diretory and
git clone git@<host>:<organization>/<repository>.git
- To view your current branch and changes:
git status
- To view commit history on current branch:
git log
- To get lastest code:
git pull origin <branch_name>
while in your repostory directory - To view all local branches:
git branch
- To create a branch:
git checkout -b <branch_name>
while in your repostory directory - To stage for commit: add changes using
git add <file_name> <file_name_2>
orgit add -a :/
to take all changes - To commit:
git commit -m '<add commit comment here>'
- To push changes to your feature branch:
git push origin <branch_name>
- To switch branches:
git checkout <branch_name>
while in your repostory directory - To rebase a feature branch onto a target branch: pull latest on target, check out to feature branch then
git rebase <target_branch>
- In the event of conflicts:
git mergetool -t meld
, select the desired changes to the middle section, save, then push to your feature branch. Retry rebase.
- To clean up your links to the remote repository:
git remote prune origin
- To delete local copies of old branches:
git branch -D <branch_name>
- To clean up trash:
git gc --aggressive
(this may take a while-- you don't need to run it often.)