This is the first time I use Git course notes, these are for Git beginners reference.
GitHub is a Git-based code hosting platform, subscribers can build a private warehouse, we generally free users can only use public warehouse, which is the code to open. This is a public warehouse for the average person would have been sufficient.
1. Register for an account and create a warehouse
To use GitHub GitHub first step of course is to register the account. Then you can create repositories (free users can build public warehouses), Create a New Repository, fill out name Create, then there will be some of the configuration information repository, which is a git simple tutorial.
2. Install Client tortoiseGit
GitHub is a server-side, in order to use on their computers, we also need a git git client, I've chosen TortoiseGit, he gives us to operate graphical interface. Before installing first need to install git, Download http://msysgit.github.com/,TortoiseGit Download: http: //code.google.com/p/tortoisegit/
Right after Bahrain will be more number of options in the local warehouse right choice Git Init Here, it will be more a .git folder, which represents the local git created successfully. Right into the git Git Bash command line, in order to local warehouses spread github, also you need to configure ssh key.
3. Configure Git
(1) First, create a ssh key locally;
$ Ssh-keygen -t rsa -C "email@example.com"
Your_email@youremail.com back to your mailbox, and then will be asked to confirm the path and enter the password, which we use the default way to enter the line. Successful will generate .ssh folder ~ / under, inside, open id_rsa.pub, copy inside the key. Back to github, enter Account Settings, select the left SSH Keys, Add SSH Key, title just fill paste key.
(2) In order to verify whether the success in git bash, enter:
$ Ssh -T firstname.lastname@example.org
If this is the first time you will be prompted whether to continue, enter yes you will see: You've successfully authenticated, but GitHub does not provide shell access. This means that has been successfully connected to github.
(3) Next, we need to do is to spread github up local warehouse, before also need to set the username and email, because github are recorded every time they commit.
$ Git config --global user.name "your name"
$ Git config --global user.name "your name" $ git config --global user.email email@example.com
(4) to be uploaded into the warehouse, right git bash, add a remote address:
$ Git remote add origin firstname.lastname@example.org: yourName / yourRepo.git
Back yourName and yourRepo represent you then github username and just the new warehouse, after completion of the addition into the .git, open the config, there will be more of a remote "origin" content, which is just to add remote address, you can directly modify config to configure the remote address.
4. Submit, upload
(1) Next, add some files in the local warehouse, such as README,
$ Git add README
$ Git add README $ git commit -m "first commit"
(2) upload to github:
$ Git push origin master
git push command will push the local repository to the remote server.
git pull command to the contrary.
After modifying the code, you can see the difference between using the git status file using git add to add files you want to commit, you can also use git add -i to add intelligent file. After submission of this revision git commit, git push upload to github.
.gitignore name suggests is the need to tell git to ignore files, this is a very important and very useful document. Generally, we will execute the code written after compiling, debugging and other operations, this period will have a lot of intermediate files and executable files, these are not the code file, git is not required to manage. We will see in the git status when many such files, if git add -A to add, then they would have added to the list, and manually add one by one, then too much trouble. Then we need to .gitignore up. Such as general c # project I .gitignore is written like this:
bin and obj is compiling a directory, which is not the source code, ignore; suo file is vs2010 configuration file, do not. So when you git status you will only see the source code files, and you can rest assured that the git add -A.