How to use Git and GitHub Warehouse management projects under Windows

Source: Internet
Author: User
Tags how to use git server hosting using git

First, download and install git

There are several implementations of the current version of Windows Git, but we chose the Msysgit release, which is the best compatibility for the time being.

: http://code.google.com/p/msysgit/downloads/list

Install git using the default configuration. This needless to say, all the way next, if you are unfamiliar with the various options, it is recommended to use the default configuration, no problem.


Second, create a GitHub account

What is git and GitHub

Git -the Stupid content Tracker, a fool-tracking device, is a distributed version control software created by the Linux kernel developer Linus to better manage the development of the Linux kernel.

GitHub -Students do version control the most annoying is to find the server, configuration is too troublesome. GitHub This site provides each user with a server hosting its Git code base, with free space of 300M. You'll have 0.3G of free space after you sign up for GitHub, but you can only create public items .

Why not choose CVS or SVN
    • Git commits/clones the/pull/push faster
    • Most git operations can be done locally, without the need to connect to the server frequently .
Sign up for a GitHub account
    • GitHub URL is here
    • Click on the signup and pricing of the upper navigation bar to enter the registration screen and select Register free account


    • The default mode of communication GitHub chooses is SSH, so first generate Shh Key in git and open git bash to enter the following command:

Ssh-keygen-t rsa-c "[Email protected]"

You will then be asked to choose whether to encrypt the folder where SSH key is stored, which is generally not required. all the way to the return, OK.

    • In the C drive, under the current User folder, there is an. ssh folder, where you find the Id_rsa.pub file, open it with Notepad, and copy all of it.
    • Log in to your GitHub account, click Accounts Settings > SSH public keys > Add Another public keyto Id_ The contents of the rsa.pub are copied in.
    • At this point, the basic setup is complete.
It became. Test your Git
    • With the above configuration, your GTI should be able to connect to the GitHub server via SSH, let's test and enter the following command:

    • Will give you such a hint:

    • Enter Yes to display:

    • Here, it means that your SSH is working well.

If you are prompted with an incorrect key, then you need to reconfirm that the previous step was complete and correct.


Third, build a local git repository


First, git requires the user to provide their own identity, so we need to execute the following command in Git bash:

git config--global user.name ' aa. Tessst '
git config--global user.email [email protected]


Second, choose the Git repository directory

Let's assume that the git repository directory is placed in the OpenSource directory of the D drive , which can be done by executing the following command in Git bash:

cd/d
mkdir opensource

Note: Git bash supports most Linux bash terminal commands, and you can try more terminal actions yourself.


Finally, build the project and initialize the GIT repository

Our first project is to use the Python language to convert an XML file into a Python dictionary by executing the following command to complete this step:

mkdir python-xml2dict
CD python-xml2dict
Git init

After doing this, git will create a hidden directory (. git) in the Python-xml2dict directory, which is the repository that Git uses to manage the software version.


IV, manage your project with Git

This step is the same as using Git on Linux, just refer to my other blog posts!


V, submit the project to GitHub management, Gitpush

If the second-step test is error-free , then you can submit the local file to the GitHub repository in the following two steps.

1, after logging on to GitHub, you can find a button "creat a New Repository" in the top right, click on, after the project name , description and so on can be created, and then a prompt page, write down a similar [email Protected]:xxx/xxx.git Address, this is the address of your project.


2.

1 git remote add origin [email protected]:xxx/xxx.git2 git push-u origin masteR/ /Push the local master branch to the server's master branch, and if the server does not have this branch, create a new branch. This is also a way to create a new branch on the server

This [email protected]:XXX/XXX.git is the address above which the created project is generated. Now open your project URL and you can see that your code has been shown.


Six, sync your project from GitHub directly with Git pull

There are two ways of doing this:

1, when Git clone, direct git pull it will automatically match a correct remote URL

is because the following is configured in the config file:

1 [Branch"Master"]2 Remote=Origin3 Merge=Refs/Heads/Master

Show:

1.git is under the master this branch, the default remote is origin;

2. Use the default remote and merge when using Git pull with the specified remote and merge in the Master Brach.

2, but for their own projects , and do not have this piece of content, need to configure themselves .

1 git remote add-f origin [email protected]:/SRV/git/Project.git//If the fifth step is performed, then this sentence will not be used.2 git config branch.master.remote origin//This step: Set the default server address on the master branch to the address that Origin points to3 git config branch.master.merge refs/Heads/Master //This step: If the current branch is the master branch, then git pull directly merges the code downloaded from origin onto the master branch .Or add the--global option to use this configuration for all projects.


Recommendation: Use the second method, because if it is a Git clone project, when executing git push, because the URL is read-only in git config

[remote "origin"]
Fetch = +refs/heads/*:refs/remotes/origin/*
url = git://github.com/xxx/xxx.git
[Email protected]:xxx/xxx.git This is the way to read and write

---------------------------------


What if you submit sensitive information, such as your own password set in the code or forget to delete the upload up?

There are two ways of doing this:

1, re-modify the local code, and then submit to the server (overwrite),

2. Log in directly to GitHub before deleting the project. Delete items need to find the admin button at the top right of the GitHub website, go inside and the bottom right has a delete button, so you can delete it.


--------------------------


If a project is hosted on GitHub. You can share its URL with everyone who is interested in the project. The URL for this example is http://github.com/testinguser/iphone_project . In the summary section of the project page, you will find two Git URL addresses, as shown on the right:


Public URLs and private URLs in the summary of the right image

The public clone URL is a publicly available, read-only Git URL that anyone can use to clone the project. You can freely distribute the URL, such as posting to a personal website, and so on.

The Your Clone URL is a readable, writable URL based on the SSH protocol that can be read and written only when connected using the key corresponding to the SSH public key that is being uploaded. Other users can only see the previous public URL when they visit the project page, and cannot see the private URL.



======================================









From for notes (Wiz)

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.