Git version management 1-installation configuration and synchronization

Source: Internet
Author: User
Tags server hosting using git git shell

The original text is contained in Youdaonote, there are pictures: Http://note.youdao.com/share/?id=79a2d4cae937a97785bda7b93cbfc489&type=note environment: Git for Windows.exe;windows;git Shell for reference: 1, how to use the Git and GitHub Warehouse management project under Windows Http://blog.csdn.net/wh_19910525/article/details /81289162, GitHub official tutorial-fork A REPOHTTPS://HELP.GITHUB.COM/ARTICLES/FORK-A-REPO/3, git on Windows-push cool/HTTP/ Www.tuicool.com/articles/Qjaqqu4, how to install git-Baidu experience under Windows http://jingyan.baidu.com/article/ 90895e0fb3495f64ed6b0b50.html Text:

One, install git for Windows

There are several implementations of the Windows version of Git, and we recommend a msysgit release with good compatibility. But the official website cannot download, I downloaded the September 9, 2015 version in the Baidu Software Center.

    1. Tick "Git Bash here" and "Git GUI here" in the Windows Explorer integration option.

    2. In the adjusting your PATH environment option, the default is OK.

    3. In the "Configuring the Line Ending Conversions" option,
      First option: If it is a cross-platform project, install in Windows system, select;
      Second option: If it is a cross-platform project, install in Unix system, select;
      Third option: Non-cross-platform project, select.


Second, create a GitHub account

1. 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 .
2. Register your 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 drive C, Current Userfolder, there is an. ssh folder, found inside the id_rsa.pubFile, open it with Notepad, and copy the entire contents.
Log in to your GitHub account, click Settings > ssh keys > Add SSH key , copy the contents of the id_rsa.pub.
At this point, the basic setup is complete. 3. Test your Git
    • With the above configuration, your GTI should be able to connect to the GitHub server via SSH, let's test it and enter the following command in Git bash:

    • 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

1. 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]

Where:--global is the synchronization of authentication information to the global


2. Select 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, such as CD D: switch to D drive.

3. 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.

Four, using Git to manage and synchronize projects

1. You have already created a project and need to synchronize from server to local, you can use Git clone

git clone HTTPS project address

The clone operation contains the Init operation, which generates a hidden. Git directory.

Official website Tutorial:

2, add to Repository

Of course you can also git add *

3. Git commit

4. Push and pull

Push is uploading a local file to the server (GitHub), and pull is synchronizing the server files locally.

Error message: New project push failed with prompt:

Want to first integrate the remote changes.eg. ' Git pull ... ' before pushing.

(There is a conflict between the local code and the server code, do you need to pull it before push?) )

After push is correct, you can see the list of files on GitHub.

5. Branches, other

In the study, refer to the following:

Official website Syncing a fork:https://help.github.com/articles/syncing-a-fork/

csdn:http://blog.csdn.net/huangyabin001/article/details/35840591

Liu Co's git tutorial: http://www.liaoxuefeng.com/wiki/0013739516305929606dd18361248578c67b8067c8c017b000

Other:

1. 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.1, after logging on to GitHub, you can find a button "creat a New Repository" in the top right, after clicking, fill in the project name , description and so on can be created, and then a prompt page will appear, note similar [ Email protected]:xxx/xxx.git Address, this is the address of your project.

Note: The project address can be expressed in either HTTPS or SSH two ways.

1.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 if the server does not have This branch, this branch is created. 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.

2. Directly synchronize the project from GitHub with Git pull

There are two ways of doing this:

2.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:

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

2.1.3. When using git pull with the specified remote and merge in the Master Brach, use the default remote and merge.

2.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 has been performed, then this sentence will not be 2 git config Branch.master.remo Te origin//This step: Set the default server address on the master branch to the address that Origin points to 3 git config branch.master.merge refs/heads/master//This step setting: if The current branch is the master branch, then git pull directly merges the code downloaded from origin onto the master branch or the--global option, which is used 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.

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

3. Share

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.

Git version management 1-installation configuration and synchronization

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.