Getting started with git
If you have no access to git at all, you can now simply understand the syntax of git (typing some commands) to upload the code to a remote repository or download to a local repository (server), we should have two warehouses at this time, that is, two places to put code, one is local, and the other is remote ( such as GitHub). The enterprise or team can manage the project through Git, and each programmer simply uploads the code written by his local repository to the remote repository, and another programmer can download it to the local repository. Today we start with the installation of Git terminal software, and before that I'll briefly introduce GitHub.
git upload code
First, the preparatory work
1 . Sign up for a GitHub account.
2. Download git terminal on Windows, similar to Shell tool,: http://msysgit.github.io/
3, installation method, open the file, all the way click Next can
4, the installation is complete.
Then you can get to the point.
Second, start uploading
1. Log in to your GitHub, create a new repository on GitHub, and enter your warehouse name.
1. Create a new local repository: Now go to the project you want to upload to GitHub, right-click on the folder will appear git GUI here and git Base here, the former select the designated folder to create the local warehouse, the latter used to enter the GIT command line
Now let's choose git GUI here to create our local repository.
2. Bind the User: Now go to the project folder, right-select Git Base here, then we go to the git client command line,
Because Git is a distributed version control system, you need to fill in the username and mailbox as an identity, user and mailbox for your GitHub registered account and email
Ps:git Config–global parameter, with this parameter, means that all of your git repositories on this machine will use this configuration, and of course you can also specify a different user name and mailbox for a warehouse
3. Set SSH key for GitHub account (can be ignored)
Link HERE Jump: http://blog.csdn.net/hustpzb/article/details/8230454/
PS: In fact, the third step can also skip, for beginners to directly use HTTP upload on the line, understand and then to understand SSH encrypted upload, here I will simply drop the HTTP upload, in fact, there is no big difference, the following steps are the same
4. Submit Local Code
Enter $ git init to start creating
1), in the local warehouse directory to create a new file you want to upload, such as my upload file is readme.txt
2), at the command line input, upload the file uploaded to the local repository:
$ git Add readme.txt
$ git commit-m ' readme.txt '
:
4), Associated remote Warehouse
This link is a link to the new warehouse on GitHub.
$ git Remote add origin master https://Github.com/starforlove/weixin-buycar
3), push code to the server
After the code has been uploaded to the local repository, the next thing to do is very simple, as long as the local code to the server on the line.
Next it will prompt you to enter your username and password, which is the name you registered on GitHub, the password is your login password
4), now that you have uploaded the success, login to your GitHub account, you can see the files you uploaded (Readme.txt is my upload ~)
5) If the upload is unsuccessful, it may be because your remote repository already exists files, and your local warehouse files are inconsistent, or your local warehouse files are not up-to-date, this time, you need to execute the following line of command:
$ Git pull Origin Master
Re-download the files from the remote repository to the local repository and execute the
Third, delete the remote warehouse do not want files
PS: What if we upload a file that you do not want after uploading the project? It's fucked up on GitHub. We are unable to directly delete the warehouse files, we can only use the terminal command to delete the files or directories we do not want
How Git deletes remote server files while preserving local files
When uploading the project to git, it is sometimes necessary to upload some of the local eclipse configuration files to the server, when you first delete the local, then synchronize the server, it is obviously unreasonable. GIT provides a good solution to directly delete the server files without affecting the local files, the command is as follows
git rm--cached filename/-"xxxx"git push
1. Delete server files, local reserved
git rm--cached useless. Log -M "Remove file from remote repository"git push
At this point, no longer exists on GitHub.
2. Delete remote useless folder, local reserved
It is important to note that deleting a folder uses the-R parameter
git rm--cached-m "Remove directory from remote repository"git push
About the use of git introduced here, learning and time learning, is really a good way to learn, the things you have learned through the blog to sort out really greatly deepened the degree of my mastery.
Of course, this is the first time to write a blog, the shortcomings of the hope that we all forgive.
2017-08-13
By the gorilla Crazy
Git upload code to github and git delete files and files on GitHub commands