Git: submit a project to Github. Git: submit a project to Github.

Source: Internet
Author: User

Git: submit a project to Github. Git: submit a project to Github.
Submit the project to Github

Recently I changed Git to submit a project, which is easier to use than SVN, but different concepts also make it difficult for beginners to adapt to git's commit method.
Today, I encountered some problems during push, such as what is the case of add. The following is a summary:
(I will not write it after I connect to my github. For details, refer to the github tutorial)

The steps are as follows (input in Bash ):

Mkdir test // create the directory cd test // enter git init // generate in the current directory. git Directory, which is a repository; the current directory is the workspace touch README // find a file git add README // add a file to the local version library git commit-m'first commit '// set commit and comments // add to your githubgit remote add origin git@github.com: youusername/test. git // push to git push-u origin master
Git Common commands get Git Repository

Initialize a version Repository
Git init

Clone remote version Library
Git clone git@xbc.me: wordpress. git

Add the remote repository origin. The syntax is git remote add [shortname] [url].
Git remote add origin git@xbc.me: wordpress. git

View remote Repository
Git remote-v

Submit your modifications

Add the modified file to the temporary storage area
Git add.

If you automatically track files, including those that have been manually Deleted and are in the Deleted status
Git add-u

Submit your modifications
Git commit-m "your comments"

Push your updates to the remote server. Syntax: git push [remote name] [local branch]: [remote branch]
Git push origin master

View File status
Git status

Tracking new files
Git add readme.txt

Remove files from the current trail list and delete all files
Git rm readme.txt

Only deleted in the temporary storage area. The files are retained in the current directory and will not be tracked.
Git rm-cached readme.txt

Rename a file
Git mv reademe.txt readme

View submitted history
Git log

Modify the comments submitted last time using the-amend Parameter
Git commit-amend

If you forget to submit some modifications, only one of the following three commands will be submitted.
Git commit-m "add readme.txt"
Git add readme_forgotten
Git commit-amend

Suppose you have used git add. To add the modified files a and B to the temporary storage Zone
Now you only want to submit file a and file B.
Git reset HEAD B

Cancel File Modification
Git checkout -- readme.txt

Basic branch management

Create a branch
Git branch iss53

Switch the working directory to iss53
Git chekcout iss53

Combine the preceding commands to create the iss53 branch and switch to iss53.
Git chekcout-B iss53

Merge iss53 branches. The current working directory is master.
Git merge iss53

After merging, no conflict occurs. Delete the iss53 branch.
Git branch-d iss53

Pull the data from a remote repository. The syntax is git fetch [remote-name].
Git fetch

Fetch pulls the latest remote warehouse data but does not automatically go to the current directory.
Git pull

View remote Repository Information
Git remote show origin

Create a local dev branch to track the develop branch of the remote Repository
Git checkout-B dev origin/develop

Reference: Git Common commands

Copyright Disclaimer: This article is an original article by the CSDN blogger Lunatictwo and cannot be reproduced without the permission of the blogger.

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.