How to quickly sync a github warehouse with Msysgit

Source: Internet
Author: User
Tags git commands

GitHub is an open source project code hosting site that is believed to be used by a lot of people, and its power is not said. If you are on GitHub for the first time, you may have a headache with synchronizing your repositories and remote repository files, because syncing requires msysgit(git for Windows) and Git commands to complete.

Here's a detailed introduction to how to quickly sync your github repository with Msysgit.

Detailed steps:
1. Before using Msysgit, login to the GitHub site to create a new warehouse, this is the warehouse to be synchronized (the name of the warehouse below is Pano)

2. After doing this, you can start using mysysgit, open git Bash, and prepare to enter GIT commands

3. Configuring Msysgit and initializing the local repository

3.1. First create the SSH Key locally and enter the following command in Git bash:

Ssh-keygen-t rsa-c "Your email"

e-mail to your email address, it is best to use your registered account when the mailbox, and then let you enter the path and password, keep the return to the default is the line, if the following actions also let you enter these, the same return to the default.
If successful, the key is generated in the c:/users/user name/.ssh/folder, and the Id_rsa.pub file is opened in Notepad and copied.


3.2. Go back to GitHub website, go to account Settings, choose SSH keys, add ssh key, paste the key that you just copied, title lose.

3.3. Verify success, enter in Git bash:
ssh-t [email protected]
The first time will prompt whether continue, enter Yes, if you see:
......
You ' ve successfully authenticated,but GitHub doesnot provide shell access.
The instructions are already connected to GitHub.
3.4. Then set the username and email to continue typing in git bash:

git config--global user.name "your name"
git config--global user.email "your email"

Replace the above your name and your email with your username and email.

3.5. Create a new local repository with the name that matches the warehouse on the GitHub Web page and execute the following command in turn:

mkdir Pano
CD Pano
git init

After the execution, you will see the Pano folder in the c:/users/username/below, there is also a. git folder (this folder is hidden, to open the show hidden, to see).

3.6. Add a remote address for the local warehouse

git remote add origin [email protected]:neil173352/pano.git

[Email protected]:neil173352/pano.git is actually the SSH clone URL, this address can be found in the new repository on GitHub,
Neil173352 is my user name, Pano is the warehouse name. When you are finished, open the config file in the. git folder of your local repository, and you can see the remote address "origin" that you just added.

3.7. The next thing to do is to synchronize the local warehouse with the repositories on GitHub, and you can create a new file to test it.

Touch Test
git add test
git commit-m ' first commit '

A new test file is created in the local warehouse, and the remote repository does not have this file.

3.8. Submit the file to a library in GitHub and execute the following command:

git push-u Origin master

This step, an error message appears:
[email protected] ~/pano (master)
$ Git push-u Origin master
to [email protected]:neil173352/pano.git
 ! [Rejected] Master--master (fetch first)
error:failed to push some refs to ' [email protected]:neil173352/pano.git '
Hint:updates were rejected because the remote contains work the
Hint:not has locally. This was usually caused by another repository Pushin
hint:to the same ref. Want to first integrate the remote changes
hint: (e.g., ' git pull ... ') before pushing again.
Hint:see the ' Note about Fast-forwards ' "Git push--help ' for details.

3.9. Before you do the push, you must pull the files from the local repository and the remote repository first, or you will see the error in the previous step:

git pull [email protected]:neil173352/pano.git master

after the above operation is finished, check if a test file is added to the remote repository and the upload is successful. Msysgit not only can upload a file, you can also upload a folder, just need to change the git add after the test to the folder name, if the folder is copied to the local repository, and then submit git commit-m ' xxx ', so just put the good project in the local warehouse, It's so easy to upload a project to GitHub with the git bash command sync!

How to quickly sync a github warehouse with Msysgit

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.