Upload projects to github based on gitbash under windows

1. Introduction to
GitHub GitHub is a website that uses Git to provide free code hosting services (similar websites and the old SourceForge), and many famous projects are hosted on it. To participate in open source projects on GitHub, depending on how Git is used, there are two ways to do it:
The first is for the creator of the project to add you to the project's list of co-contributors, so you can directly contribute to the project Push code.
The second is to Fork a piece of code to your own space, and such a piece of code has the permission to push. If the development is progressing well, the creator of the project can add these projects of the Fork as a Remote repository, and fetch the code to his own repository for merging when he thinks fit, or we can initiate a request, ask the founder to add Code merge. What is advocated on GitHub is to use this method for development cooperation.
GitHub can host various git repositories and provide a web interface, but unlike other services like SourceForge or Google Code, GitHub's unique selling point is the ease of forking from another project. Because GitHub is based on the Git version
control system, you need to use Git tools to upload and modify code   . GUI and bash administration tools. msysgit is recommended. msysgit is the Windows version of Git. Download it from https://git-for-windows.github.io/ and install it by default. 3. Configure Git 1. Configure ssh key









In order to transfer the local repository to github, you also need to configure the ssh key. Enter the GitBush command line and enter the following command:
$ ssh-keygen -t rsa -C "[email protected]"
Generating public/private rsa key pair. #Prompt that the rsa key pair is being generated
Enter file in which to save the key ( /c/Users/Administrator/.ssh/id_rsa): #Ask ​​where the public key and private key are stored, press Enter and use the default location to
enter passphrase (empty for no passphrase): #Ask ​​to enter the private key passphrase, enter the passphrase
Enter same passphrase again: #Prompt to enter a passphrase again to confirm
Your identification has been saved in /c/Users/Administrator/.ssh/id_rsa.
Your public key has been saved in /c/Users/Administrator/.ssh/id_rsa.pub.
# Prompt that the public key and private key have been stored in the /c/Users/Administrator/.ssh/ directory

2. Enter the SSH key into
the : Account Settings->SSH Pbulic Keys>Click Add another public key
Enter the newly created key into key and add a title, for example: git-tutorial. That is /Users/your_user_directory/.ssh/id_rsa. By default. ssh is a hidden file, you need to set the system to show hidden files to see. After the input is complete and click Add key, you will see that git-tutorial has been added. You will receive a confirmation email with the email you filled in, don't care about it.

To verify success, enter under git bash:
$ ssh -T [email protected]
Warning: Permanently added the RSA host key for IP address '192.30. 253.112' to the
list of known hosts.
Enter passphrase for key '/c/Users/Administrator/.ssh/id_rsa':
Hi mfcai! You've successfully authenticated, but GitHub does not provide shell a ccess
.
Successfully connected to github

4. Use GitHub to build warehouses
      The types supported by Github hosting projects, one is User/Organization Pages, the other is Project Pages, which are the two basic types supported on the two Github hosting websites.

User/Organization Pages
      This is a second-level domain name assigned by Github for each account, but it should be noted that it must start with your username, otherwise it cannot be accessed.
Project Pages
      In addition to the above-mentioned warehouse named after its own name, everything else built can be regarded as Project Pages. However, in order to achieve access to the page, you need to create a gh-pages branch to access it.
We use User/Organization Pages to build the warehouse.


Fifth
, create a new repository and host the code on GitHub. A repository (warehouse) can put a project. We use GitHub for Windows software to create a new local repository.

You also need to set username and email before this, because github will record them every commit
$ git config --global user.name "mfcai"
$ git config --global user.email [email protected] use

in github windows tools git Bash open the project, use the cd command to enter the root directory of the existing project
1. Initialize the local warehouse $
git init //Generate local git management in the current project directory, and create a hidden
.
'# test ' >> README.md
$git add README
Upload your own project to github, which can be roughly divided into four steps: add, commit, remote, push
3.add (select the file to be added in the warehouse)
$ git add . //(. means to upload all the files in this folder. If you need to upload the specified file, you can specify the file name)
4.commit
$ git commit -m 'Test'
//-m is followed by a prompt message. This prompt message must be written, not only a rule, but also convenient for us to record the process of our submission, and it is very useful to write clearly why we submitted or modified what
5 .remote
$ git remote add origin [email protected]:yourName/yourRepo.git
//Connect to the remote repository and create an alias named origin
Sometimes when you enter this statement, github may "drop the line". Will report fatal: remote origin already exists. This error. At this time, you only need to enter
$ git remote rm origin and then enter the above code.
6.push
$ git push -u origin master
// Submit the contents of the local warehouse to the address of origin, under the master branch

This article welcome to reprint, But please indicate the author and source
Author : Meteor
Source: http://blog.sina.com.cn/staratsky

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326118999&siteId=291194637