Clone a remote repository locally
- cd to target directory
- git clone <remote uri>
Change local branch
- git checkout <branchname>
Create a local branch and Push to remote branch
- git checkout -b <branchname>
- git add .
- git commit -m “commit message”
- git push -u origin <remote-branchname>
- e.g
- git push -u origin master
- git push -u origin dev
Overwrite all local changes from remote (origin)
- git fetch –all
- either:
- git reset –hard origin/master
- git reset –hard origin/<branchname>
Push same code to a second remote (skills421)
- git remote add skills421 https://github.com//.git
- git push -u skills421 master
Delete a local branch
- use
-D
instead to force deletion without checking merged status - git branch -d <branchname>
- git branch -D master
Delete a remote branch
- git push origin –delete <branchname>
- e.g
- git push skills421 –delete dev
Merge dev into master
- git checkout master
- git merge Dev
- git checkout Dev
Push to origin and reset to very top of tree, replacing all history
- git push origin +master
List remote repositories for current local
- git remote -v
List branches
- git branch -a # list all local and remote branches
- git branch # list all local branches
- git branch -r # list all remote branches
Branch master set up to track remote branch master from skills421
want to change it to track origin
View Git Commits
git log