http://hao.jobbole.com/try-git/
If you create a new project now, would you like to submit it to GitHub?
Let's say you've created a project and switched to the project's root directory:
$ git status//view the status of all the articles under the current project, if first you will find all the red color as it has not been handed over to Git/github management.
$ git Add. The (.) dot represents everything under the current directory and is given to git management, which is the local repository that was committed to git.
Ps: The power of git is that there is a concept of a local repository that can submit the updated content to the local repository without a network.
$ git commit–m "new Natter" //A description of what you have updated or modified.
$ git Remote add origin [email protected]:d Efnngj/hibernate-demo.git
If you are submitting your project for the first time, this is a very important sentence, which is the current project in your local connection to the remote repository.
Ps: origin can be changed to someone else's name, but the next time you push (submit), you will have to use your modified name.
$ git remote-v //view which warehouse address your current project is remotely connected to.
$ Git push-u origin master //submits the local project to the remote repository.
------------------------------------------------------------
If you were back home, would you like to clone the project submitted by the company locally?
If this is the first time you want to clone a project above GitHub to a local or clone someone else's project to the ground.
$ git clone [email protected]:d efnngj/hibernate-demo.git //switch to the file directory where you want to store the project under Git, and run this command to clone the project.
If the project already exists locally and there is a new update in the repository, how do I merge it into a local project?
$ GIT fetch origin //Get remote update, here can be considered as ready to take a
$ git merge origin/master //merge the updated content into the local branch/master
-------------------------------------------
Some files were deleted in the project, how do I submit them?
If the remote warehouse has already saved AAA This file, I fetch down, and delete the AAA this file, want to push on to the remote repository again, and make the project in the remote warehouse is overwritten by the new modification (also the AAA in the remote Warehouse is deleted)
$ git status //can see which files we deleted
$ git Add. Delete the files after committing to git administration.
$ git RM src/com/hzh/hibernate/dao/aaa.java //Remove the file we deleted, or git won't allow us to commit to the remote repository.
Ps: If you want to delete a directory (Java package), you want to remove the contents of the entire directory.
$ git RM src/com/hzh/hibernate/bbb/-R /- R will move all the contents of the bbb/directory once.
------------------------------------------------------------------------
A new warehouse was created remotely, and a new project was created locally, how to make the new project correspond to the warehouse?
In fact, this is very simple, but I was not very understanding of those orders, so more vague, I do not know how to correspond.
$ git Remote add origin [email protected]:d Efnngj/hibernate-demo.git
Or this command, add this sentence before you push the project OK.
[email protected]:d Efnngj/hibernate-demo.git is the address of your common new warehouse. git switches to the new project, before push, with this sentence, the new warehouse we created is connected to the new project.
Attention:
1. The process of generating SSH keys can be consulted in the official documentation Https://help.github.com/articles/generating-ssh-keys
2. Use git bash to execute commands instead of Windows CMD to avoid unnecessary problems with tools such as Cygwin and MinGW installed in the system.
3.GITHUB official recommended push and pull codes using HTTPS
4. When using HTTPS, the user name is not associated with the files and is not displayed in contributions when the commit code is used. However, in public activity, the local user name is associated (linked to the home page).
5. To associate a user name to a github user, the User.email must be set to the email address used to register the account.
15 minutes to learn git basic operation commands