9. Most Useful Commands
$ git init
$ git add .
$ git commit -m “Message”
$ git checkout [-b] branch_name or commit_hash
To initialize a repository:
To add all files to staging area:
To add staged files to local repository
To [change / create] branch or go back to previous version:
$ git merge br1 br2
To combine two branches:
$ git status
To check the status of the repo:
10. Working Directory
$ git status
On branch master
Initial commit
Untracked files:
(use "git add <file>..." to include in what will be committed)
comments.txt
cpp_code.cpp
ruby_code.rb
nothing added to commit but untracked files present (use "git add" to
track)
1
11. Staging Area
$ git add .
$ git status
On branch master
Initial commit
Changes to be committed:
(use "git rm --cached <file>..." to unstage)
new file: comments.txt
new file: cpp_code.cpp
new file: ruby_code.rb
2
12. Local Repository
$ git commit -m "My First Commit"
[master (root-commit) 1e74cf1] My First Commit
3 files changed, 0 insertions(+), 0 deletions(-)
create mode 100644 comments.txt
create mode 100644 cpp_code.cpp
create mode 100644 ruby_code.rb
(master) $ git status
On branch master
nothing to commit, working directory clean
3
14. A web-based Git repository hosting service,
which offers all of the distributed revision control
and source code management (SCM) functionality
of Git as well as adding its own features.
16. Connecting Your Local
Repository To GitHub
$ git remote add origin https://github.com/Username/Repo.git
$ git push [-u] origin master [or branch_name]
To add a remote:
To push the changes to the newly created repo:
17. Most Useful Commands
$ git push origin [-u] branch_name
$ git pull origin branch_name
To upload your changes to GitHub:
To download your team’s changes: