GitHub Linux command-line operation example

Source: Internet
Author: User
Tags diff file url gpg tidy git commands

Go ahead and tidy up Linux. Use the command line operation instance below

First create a file directory and then perform a git clone operation

[Email protected]:~/Desktop $ cd test/[email protected]:~/desktop/test$ git clone https://github.com/timelessz/ Testdemo.git
Being cloned to ' Testdemo ' ...
Remote:counting Objects:3, done.
Remote:total 3 (Delta 0), reused 0 (Delta 0), pack-reused 0
Unpacking objects:100% (3/3), done.

Here's how to perform a git--help operation

[Email protected]:~/desktop/test$ git--Help usage: git [--version] [--help] [-c <path>] [-C name=value] [--exec-path[=<path>]] [--html-path] [--man-path] [--info-path] [-p|--paginate|--no-pager] [--no-replace-objects] [--bare] [--GIT-DIR=<PATH&G t;] [--work-tree=<path>] [--namespace=<name>] <command> [<args>] The most common git commands are: Add File content to index bisect introduce bugs by binary lookup location Change branch list, create, or delete a branch checkout check out a branch or path to workspace clone clone a repository to a new directory commit record change to Repository diff show differences between commits, commits, and workspaces download from another repository object and reference grep output and pattern matching line init create an empty Git repository or reinitialize an existing repository log display commit log merge combine two or more dev history mv Move or rename a file, directory or symbolic link pull to get and integrate another version Library or a local branch push updates a remote reference and related objects Rebase local commits to the updated upstream branch reset resets the current head to the specified state RM removes files from the workspace and index show displays various types of objects status Display workspace state tag Gen Build, list, delete, or verify a GPG-signed tag object     

Test create a new file and upload it

[Email protected]:/home/timeless/desktop/test/testdemo# vi demo[email protected]:/home/timeless/Desktop/test/testdemo# git Add. / *[email protected]:/home/timeless/desktop/test/testdemo# git commit***. Run  git config--global user.email "[email protected]"  git config--global user.name "Your name" to set Your Accoun T ' s default identity. Omit--global to set the identity of the repository.fatal:unable to Auto-detect email address (got ' [email protecte D] (none) ')  

Encountered an error, is not running git config--global user.email "[email protected]" to indicate my identity.

You can run the statement.

[Email protected] notebook-pc:/home/timeless/desktop/test/testdemo# git config--"[email protected]"[email protected] :/home/timeless/desktop/test/testdemo# git  commit-a-  m first time commit   

Git commit operation parameters:
Usage: git commit [options] [--] < path rules >...-Q,--Quiet does not display overview information after a successful submission-V,--Verbose Show Variance Submission Description option-F,--file < file > in Submission description templateRead the submission description from the file--author < author >Overwrite author--date < date > on submissionDate covered on submission-M,--message < description >Submission Instructions-C,--reedit-message < submit >Reuse and edit the submission instructions for the specified submission-C,--reuse-message < submit >Reuse the submission instructions for the specified submission--fixup < submit >Use the submission instructions in the Autosquash format to fix the specified submission--squash < submit >Use the submission instructions in the Autosquash format to compress to the specified submission--reset-author now change the author of the submission to me (and-c/-c/--Amend parameters shared)-S,--signoff add signed-off-By: Signature-T,--template < files >Use the specified template file-E,--Edit Force Editor Submit--cleanup <Default>Set how to delete spaces and # comments in the commit description--Status contains state information in the submission description template-S,--gpg-sign[=<key id>] GPG Submit Signature Submission Option-A,--All commit all changes to the file-I,--include add the specified file to the index area to wait for submission--interactive Interactive Add File-P,--< Span style= "color: #000000;" >patch Interactive Add Change-O,--only commits only the specified file-N,--no-verify bypasses Pre-run shows what will be submitted--short Displays the status in a concise format--branch Show branch information--porcelain machine-readable output--longnull entry ends with nul character--amend Modify previous commit--no-post-rewrite bypass post-< Span style= "color: #000000;" >rewrite hook-to-U,--untracked-files[=< mode >

Perform a git push push

[Email protected]:/home/timeless/Desktop/test/testdemo# git pushusernameFor‘Https://github.com‘: TimelesszpasswordFor‘Https://[email protected]‘: Counting objects:4, done. Delta compressionusing up to 4 threads. Compressing objects: 100% (2/ 2), done. Writing objects: 100% (3/ 3), 305 bytes | 0 bytes/s, done. Total 3 (Delta 0), reused 0 (Delta 0) to https:< Span style= "color: #008000;" >//github.com/timelessz/testdemo.git a01a7c2. b15b255 Master, Master             

Exception handling

Instance a new Linux command line instance is opened

New folder execution git clone file URL

[Email protected]:~/desktop/demo$ git clone https://Github.com/timelessz/testdemo.git is cloning to‘testdemo ...remote: Counting objects: 6 Done.remote:Compressing objects: Span style= "color: #800080;" >100% (3/3), Done.remote:Total 6 (Delta 0), reused 3 (Delta 0), pack-reused 0 unpacking objects: 100% ( 6/6), done. Check the connection ... Complete. [email protected]:~/Desktop/demo$ lstestdemo      

Modify a file in a new session

[Email protected]:~/desktop/demo/testdemo$ lsdemo  readme.md

[Email protected]:~/desktop/demo/testdemo$ git Add.
[Email protected]:~/desktop/demo/testdemo$ git commit-a-M "Second Test"
[Master 6b98505] Second Test
1 file changed, 1 insertion (+), 1 deletion (-)
[Email protected]ion-g4-notebook-pc:~/desktop/demo/testdemo$ git push

GitHub Exception Handling:

[Email protected]:/home/timeless/Desktop/test/testdemo# VI Demo//modify local file simultaneously submit [email protected]:/home/timeless/Desktop/test/testdemo# git Add. [Email protected]:/home/timeless/desktop/test/testdemo# git commit-a-M"Zhaoxing Testing Conflict exceptions"//Submit File Discovery issues[Master d948414] Zhaoxing test conflict exception1 file changed,1 insertion (+),1 Deletion (-) [Email protected]:/home/timeless/desktop/test/testdemo# git pushusernameFor‘Https://github.com‘: TimelesszpasswordFor‘Https://[email protected]‘: to https://Github.com/timelessz/testdemo.git! [Rejected] master,Master (Fetch first) Error: Unable to push some references to‘Https://github.com/timelessz/TESTDEMO.git'//Version exceptionTip: The update is rejected because the remote repository contains commits that you do not already exist locally. This is usually due to another hint: a repository has been pushed to the reference. Before you push again, you may need to consolidate the remote change hints first:‘Git pull ...‘)。 Tip: See‘git push--help' In the‘Note about Fast-forwards‘Section. [Email protected]:/home/timeless/Desktop/test/testdemo# git pull//first pull down to solve the problem remote:counting objects:3, done.remote:Compressing objects:100% (2/2), Done.remote:Total3 (Delta0), reused3 (Delta0), pack-reused0Unpacking objects:100% (3/3), done. From https://Github.com/timelessz/testdemo b15b255. 6b98505 Master--origin/Master Auto Merge demo conflict (content): Merge conflicts in Demo auto merge failed, fix conflict and then submit corrected result. [Email protected]:/home/timeless/Desktop/test/testdemo# git Diffdiff--CC Demoindex 8677aea,fc19e2b.0000000---A/demo+++ b/demo@@@-1,1-1,1 +1,5@@@++<<<<<<<HEAD +Zhaoxing test implementation of exception version ++=======+Zhaoxing Test Implementation I don't like files ++>>>>>>>6b98505ba81551d18ad01e82f59dc7ae3e6f1d5e[email protected]:/home/timeless/Desktop/test/testdemo# VI demo//modified file after processing version [email protected]:/home/timeless/desktop/test/testdemo# git Add. [Email protected]:/home/timeless/desktop/test/testdemo# git commit-a-M"After dealing with conflicts"[Master f7a190d] After dealing with the conflict [email protected]:/home/timeless/desktop/test/testdemo# git pushusernameFor‘Https://github.com‘: TimelesszpasswordFor‘Https://[email protected]‘: Counting objects:8, done. Delta compressionusing up to 4 threads. Compressing objects: 100% (3/ 3), done. Writing objects: 100% (4/ 4), 534 bytes | 0 bytes/s, done. Total 4 (Delta 0), reused 0 (Delta 0) to https:< Span style= "color: #008000;" >//github.com/timelessz/testdemo.git 6b98505. f7a190d Master, Master             

Exception handling is complete.

Forums to collect others on the use of GitHub experience:

    • Multi-use tools, less command line, unless forced to use a Linux server.
    • Before submitting the first diff code, one side error.
    • Tidy up your work area before you get home from work, save time and prevent code clutter the next day.
    • Parallel projects, such as a lot of modules need a piece of development, using branch development, effectively reduce project risk.
    • Push encounters a conflict, figuring out the cause of the conflict and not asking for someone else's code.
    • After the release of the product remember to hit the bug, to facilitate future pull branch to modify the bug.

GitHub Linux command-line operation example

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.