Some useful git command with branches and remote repositories.
Remote operations
List remotes:
git remote -vAdd remote gitosis server:
git remote add <remote_name> git@myhostname.com:my_project_name.git
git push <remote_name> masterWhere master is your branch name
Main git branch orperations
list branches:
git branch -v-v is optional, you use it to get more verbose output
Create new branch:
git checkout -b <new_branch_name>
Merge
git checkout <a_branch>
//do something
git commit -am 'I did something'
git checkout <b_branch>
git merge <a_branch>Delete branch:
git branch -d <branch_name>Reset an old commit state
Warning: you always clone your repository before try these commands!
You can undo everything you've made since last commit. Uncommited modifications will be lost.
git reset --hard HEADRemove the last 3 commit. Commits will be removed from git forever:
git reset --hard HEAD~3Undo uncommited changes for a specified file:
git checkout -- <file_name>
Add new comment