Upload local code to GitHub

Source: Internet
Author: User
Tags using git

First step: Build a git repository
CD to your local project root directory, execute the git command
Git init
Step Two: Add all the files of the project to the warehouse
git Add.
If you want to add a specific file, simply change it to a specific filename.
Step three: Commit the Add file to the repository
git commit-m "comment statement"
Fourth step: Create your own repository on GitHub and get the HTTPS address of the warehouse you created after you've created it
Fifth step: Focus on the local warehouse to GitHub
Git remote add Origin https://github.com/dinphy1205/ido_flyme_devices_base_cm
Sixth step: Before uploading GitHub, pull it first and execute the following command:
Git pull Origin Master
Seventh step, the last step, upload the code to GitHub remote repository
Git push-u Origin Master
After execution, if there is no exception, wait for the completion of the upload successfully, the middle may let you enter username and password, you just enter GitHub's account and password on the line

Git Some wrong workarounds
1. Pull isn't possible because you have unmerged files.
Symptom: Pull when
$ Git pull
Pull are not possible because you have unmerged files.
Please, fix them-in the work tree, and then use ' Git add/rm <file> '
as appropriate-to-mark resolution, or use ' Git commit-a '
should be due to a local file conflict
Workaround:
1.pull will cause conflicts using Git merge, need to resolve the conflicting files
git add-u
git commit
git pull
2. If you want to discard local file modifications, you can use git reset--hard fetch_head,fetch_head to represent the commit point that was formed after the last successful git pull. Then git pull.
Note:
git merge will form Merge-head (Fetch-head). Git push will form a reference such as head. The head represents a reference that was formed after a local recent successful push.

In my experience, there are times when this happens somehow, and untracked files is very much (in fact, you may have changed only one or two files), so you have to save your own to make the local changes, and then use git reset--hard fetch_ Head back to the point after the last successful pull, and then pull will be fine.
2.You is currently on a branch.
Symptom: There was a pull when there was a conflict, this time with "git Reset--hard fetch_head" method is not, appear:
$ git pull
Currently on a branch, so I cannot use any
' Branch.<branchname>.merge ' in your configuration file.
Specify which remote branch you want the command
Line and try again (e.g. ' git pull <repository> <refspec> ').
See Git-pull (1) for details.
Workaround:
First of all
Git checkout-b Temp
Secondly
git checkout Master
You can revert to the Master repository state and then pull the

Upload local code to GitHub

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.