Simply copy and upload code from github using the git Tools command

Source: Internet
Author: User
Tags using git git commands

First: Copy items from GitHub to local

1. Create a project on GitHub named: Mygittest

2. Copy this project on our local computer: Select a folder directly, right-click Git Bash here

By typing the GIT clone project address directly, you can copy the project created on GitHub to local.

Second: Do some local operations and upload to GitHub projects

For example, add a images file, a style.css style sheet

1. Create a warehouse:

Git init

2. Select the files to add to the warehouse:

git Add.

In general, if you want to share all the code in this folder, add "." After add, the example above is this, if you pass the specified, only need to put "." To the file name, and now just select the files to be added to the warehouse, the following is added into the warehouse:

3. Adding descriptive information about the submission

Git commit-m ' test to see if you can commit '

-M followed by a parameter indicating that after committing the code to GitHub, the description will be displayed on the code file information, such as where the tag is.

It took so long to start uploading the local repository to GitHub, and the following two lines of command fix the problem:

You need to pull the code first to push the upload success

Continue with the following actions

(1) Git remote add origin [email protected]: Lanyanjing-2016/mygittest.git

(2) Git pull Origin Master

(3) Git push-u origin Master

This [email protected]:xxx/xxx.git is the address above which the created item is generated. Now open your project URL and you can see that your code has been shown. If you want to update the code, repeat it.

/**************** Attachment content: ******************************************/

Git commands in a detailed

Now that we have a local and remote repository, let's try to use Git's basic commands: Git Pull: Update the code locally from the other repository (which can be remote or local), for example:'git pull Origin master'is to update the code for the Origin repository to the local master primary branches, which is similar to SVN's updategit add: It is adding the current change or the new file to the Git index, which is added to the GIT index to be included in the version history. This is also a step that needs to be performed before committing, for example'git add app/model/user.rb'It will increase app/model/.user.rb files into the git index, which is similar to SVN's addgit RM: Delete files from the current workspace and the index, for example'git rm app/model/user.rb', this feature is similar to the SVN rm, Delgit 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 used when submitting-m to enter a commit message that is similar to the SVN commitgit push: Update the local commit code to the remote repository, for example'git push Origin'Will update the local code to the remote repository named orgin git log: View the history log, which is similar to SVN's loggit revert: to restore a version of the modification, you must provide a specific git version number, for example'git revert bbaf6fb5060b4875b18ff9ff637ce118256d6f20', the version number of Git is a hash value generated

The process of using Git to create a project locally:

  procedure for creating a project locally using git $ makdir  ~/hello-world / /  Create a project Hello-world  $ cd ~/hello-world //   $ git init //  initialize  $ touch readme$ git add README  // update the Readme file  $ git commit-m ' first commit ' //
       commit the update and comment the message "first commit"  $ git Remote add origin [email protected]: Defnngj/hello-world.git //  connect a remote GitHub project  $ Git push-u origin master //  To update a local project to a GitHub project  

Simply copy and upload code from github using the git Tools command

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.