$ git init
$ git clone [email protected]:username/Hello-World.git
Change username for your user name.
Change Hello-Word for your git repository name.
$ git add
$ git add -i
$ git add -p
$ git commit -am "Commit description"
This command let's you mark what you want to commit.
$ git commit --interactive
After all type your commit message on vi, 'ESC' and ':wq'.
$ git status
$ git ls-files -m
$ git log
$ git remote -v
$ git remote add origin https://github.com/username/Hello-World.git
You can change "origin" to what you prefer. Origin is just an example name.
$ git remote rm origin
Origin is just an example name. You may have other remote git repository name.
$ git push origin master
Change origin for your remote git repository name. Change master for your desired working branch name.
$ git pull origin master ~> "origin" is remote server nickname
Gets the most recent modifications from remote repository.
$ git checkout -b 'newfeature'
The above command, creates a branch called "newfeature".
$ git checkout -b "branch_local" origin/"branch_remote"
The above command, creates a new local branch called "branch_local" from "branch_remote" on "origin" remote git repository.
$ git checkout -b newbranch v1.0
$ git push origin --delete newfeaturebranchname
Change newfeature to your remote branch name.
$ git branch -d newfeature
Change newfeature for your local branch name.
$ git checkout -- init.php
$ git checkout HEAD init.php ~> obtem a ultima versao
HEAD - last modified version.
$ git log
$ git log -p
$ git log -p -2
$ git log --pretty=oneline
$ git log --since=2.days
$ git log --graph --oneline --decorate --date=relative --all --pretty=format:"%h %s"
$ git fetch
$ git diff --name-status a8e5e4e..295bf31
$ git stash
Useful if you made changes that you don't wanna commit but you need to switch to another branch.
$ git stash list
$ git stash apply
$ git reset --hard HEAD
$ git clean -df
$ git checkout -- .
$ git checkout master // goes back to master branch
$ git pull // get updates
$ git merge newfeature //merges newfeature branch into master branch
$ clip < ~/.ssh/id_rsa.pub
$ git gui
GUI for un-staging and committing.
$ gitk
GUI for visualizing commits through the time.