Git common Command Memo

Source: Internet
Author: User

git clone: This is a simpler way of initializing, and when you already have a remote git repository, you just need to clone a copy locally, like ' Git clone git://github.com/someone/some_ Project.git some_project ' command is to fully clone the remote repository of the URL address of ' git://github.com/someone/some_project.git ' to the local some_project directory


git init and git remote: This is a little more complicated, and when you create a working directory locally, you can go to the directory, initialize it with the ' git init ' command, and Git will then version the files in that directory, At this point if you need to put it on a remote server, you can create a directory on the remote server and record the accessible URL, you can use the ' Git remote add ' command to add a remote server side, such as ' git remote add origin git ://github.com/someone/another_project.git ' This command will add a URL address of ' Git://github.com/someone/another_project.git ', A remote server named Origin, which will only need to use the Origin alias when committing to the code at a later time
Now we have the local and remote repository.

gitPull: Updates the code locally from other repositories (both remote and local), for example: ' Git pull Origin master ' is updating the code for the Origin repository to the local master primary branches, This feature is similar to the SVN update


git add: is to add the current changes or new files to the Git index, added to the Git index is recorded in the version history, this is a step before committing, such as ' git add app/model/user.rb ' It will add the app/model/user.rb file to the git index.


git rm: Delete files from the current workspace and index, such as ' Git rm app/model/user.rb '


git commit: commits the changes to the current workspace, similar to the SVN commit command, such as ' Git commit-m ' story #3, add user model ', must be submitted with-m to enter a commit message


git push: updates the local commit code to the remote repository, such as ' Git Push origin ', which updates the local code to the remote repository named Orgin, if someone pushes it after you last extracted, merged, git The server will reject your push, knowing that you are up to date. So git pull is needed first


git log: View history log


git revert: to restore a version of the changes, you must provide a specific git version number, such as ' git revert bbaf6fb5060b4875b18ff9ff637ce118256d6f20 ', Git's version number is a generated hash value

git diff: compare two different points in a historical record


git branch: adding, deleting, and checking branches, such as ' Git branch new_branch ' creates a new branch called New_branch from the current working version, ' Git branch-d new_branch ' Will force the deletion of the branch called New_branch, ' git branch ' will list all local branches


git checkout: GIT's checkout has two functions, one is to switch between different branch, such as ' Git checkout new_branch ' will switch to New_branch branch, and another function is to restore the code, such as ' Git Checkout app/model/user.rb ' will update the user.rb file from the last submitted version, and all uncommitted content will be rolled back.

git merge: merges another branch into the current branch. Git automatically merges the unique work from two different snapshots into a new snapshot in the best way possible.

For detailed commands see: http://www.ihref.com/read-16369.html

Git common Command Memo

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.