- Git init
- git status
- git add readme.txt
- git add--all Adds all new or modified files
- git commit-m "message"
- git add ' *.txt ' Add all TXT file in the whole project
- git remote add originname https://github.com/try-git/try_git.git: Tell git to add a bookmark-like message for later push sharing
- Git remote-v lists all known remote lists
- git push-u originname master (
-u tells Git to remember the parameters, so, next time we can simply run and git push Git would know. Push to remote repository to share to others (via pull operation)
- Git pull Originname Master
- git diff show unstaged differences since last commit
- git diff HEAD
- git add octofamily/octodog.txt
- git diff--staged View staged differences:staged files is files we have a told git that is ready for be committed
- Git reset octofamily/octodog.txt cancel the staged octodog.txt file
- git reset HEAD LICENSE unstage staged file for LICENSE file
- Git checkout--octocat.txt retrieve latest octocat.txt and lost changes
- Git branch clean_up Create one branch to work on
- git checkout clean_up switch to the CLEAN_UP branch
- git rm ' *.txt '
- Git commit-m "Remove all the Cats"
- git checkout master switching to master branch
- git merge clean_up merge master with CLEAN_UP branch modifications
- git branch-d clean_up Delete the Clean_up branch after finished work on that branch
- Git push push all the work we finished to GitHub
- git log
- Git commit-a-M "Modify Readme" adds add to stage and commit change (add changes from all tracked files:does not add NEW FILE (untracked)!! )
- git reset--soft head^ the last commit rollback to staging area, then fix it, such as adding new files, modifying existing files, and then doing commit actions
- git add todo.txt; git commit--amend-m "forget the todo.txt in last commits, so amend it here"
- git reset--hard head^;git reset--hard head^^ undo Last/Two Commit
Common Workflow Scenarios:
Jane creates a file, adds the file to staging area, commits the commit change;
Jane modifies the Readme.txt file and adds the license file, adding these modifications to the staging area, committing the changeset
Hosted GIT Repository:github, BitBucket;
Selft Managed:gitosis, Gitorious
Git Workflow Common commands