Git Workflow Common commands

Source: Internet
Author: User

  1. Git init
  2. git status
  3. git add readme.txt
  4. git add--all Adds all new or modified files
  5. git commit-m "message"
  6. git add ' *.txt ' Add all TXT file in the whole project
  7. git remote add originname https://github.com/try-git/try_git.git: Tell git to add a bookmark-like message for later push sharing
  8. Git remote-v lists all known remote lists
  9. 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)
  10. Git pull Originname Master
  11. git diff show unstaged differences since last commit
  12. git diff HEAD
  13. git add octofamily/octodog.txt
  14. git diff--staged View staged differences:staged files is files we have a told git that is ready for be committed
  15. Git reset octofamily/octodog.txt cancel the staged octodog.txt file
  16. git reset HEAD LICENSE unstage staged file for LICENSE file
  17. Git checkout--octocat.txt retrieve latest octocat.txt and lost changes
  18. Git branch clean_up Create one branch to work on
  19. git checkout clean_up switch to the CLEAN_UP branch
  20. git rm ' *.txt '
  21. Git commit-m "Remove all the Cats"
  22. git checkout master switching to master branch
  23. git merge clean_up merge master with CLEAN_UP branch modifications
  24. git branch-d clean_up Delete the Clean_up branch after finished work on that branch
  25. Git push push all the work we finished to GitHub
  26. git log
  27. 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)!! )
  28. 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
  29. git add todo.txt; git commit--amend-m "forget the todo.txt in last commits, so amend it here"
  30. 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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.