git config --global user.name "First Last"
git config --global user.email "myname@org.com"
git init
Output:
$ git init
Initialized empty Git repository in /Users/cheenam/GitSamples/hello/.git/
git add file.txt
git commit -m "First Commit"
Output:
$ git add file.txt
$ git commit -m "First Commit"
[master (root-commit) f0ab4d3] First commit
1 file changed, 0 insertions(+), 0 deletions(-)
create mode 100644 file.txt
git status
Output:
$ git status
On branch master
nothing to commit, working tree clean
Output:
$ git status
On branch master
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git checkout -- <file>..." to discard changes in working directory)
modified: file.txt
no changes added to commit (use "git add" and/or "git commit -a")
git add file.txt
Output:
$ git add file.txt
On branch master
Changes to be committed:
(use "git reset HEAD <file>..." to unstage)
modified: file.txt
git commit -m "Changes for file.txt"
git log
git log --pretty=oneline
git log --pretty=oneline --max-count=2
git log --pretty=oneline --since='5 minutes ago'
git log --pretty=oneline --until='5 minutes ago'
git log --pretty=oneline --author=<your name>
git log --pretty=oneline --all
git log --pretty=format:"%h %ad | %s%d [%an]" --graph --date=short
git clone https://github.com/<account>/<repository>
git remote add upstream https://github.com/<account>/<repository>
git clone https://github.com/<my_account>/<my_forked_repository>
git remote add upstream https://github.com/<master_org>/<my_parent_repository>
git remote add xyzaccount https://github.com/<xyzaccount>/<repository_name>
git remote
git remote -v
git fetch <remote>
git push origin master
git remote show origin
git remote rename <current_name> <new_name>
git remote remove <remote_name>
git tag
git tag -l "v1.*"
git tag <tag_name>
git tag -a <tag_name> -m <tag_description>
git tag -d <tag_name>
git tag -delete <tag_name>
git push <remote> --d <tag_name>
git push <remote> --delete <tag_name>
git checkout <tag_name>
git checkout -b <branch_name> <tag_name>
git push <remote> --tags
git branch testing
git checkout testing
git push <remote> <branch_name>
git checkout --track <remote>/<branch_name>
git fetch --all
git branch -vv
git push <remote> --delete <branch_name>
git checkout <current_branch>
git rebase <master>
-- All new changes from <current_branch> will get copied (duplicate changesets) to <master> with a new <current_branch> HEAD
-- Useful for generating cleaner histories in running branches and ensuring branch commits are always ahead of 'master'.
git checkout <master>
git merge <current_branch>
git commit -m "My Merged commit"
-- All new changes from <current_branch> will be merged (using same changesets) to <master> without changing <current_branch> HEAD
git checkout <master>
git merge --squash <current_branch>
git commit -m "My Squashed commit"
-- All new changes from <current_branch> will be merged in a single commit to <master> wuthout changing <current_branch> HEAD
-- Always recommended when merging a big change to 'master'
Refer here: https://git-scm.com/docs/gitworkflows for full documentation.