Git and Github learning portal

Github account also registered for some time, but has to make excuses operating trouble github, we have refused to learn to escape, today, I finally no longer escape, stop and take the time and effort to learn the basics of using the operating github.
Getting Started with git and github learn
a download install
install git for windows
command line version of git this is a windows system
https://git-scm.com/downloads
Notes: Install git for windows all the way next to
two, use github
1 , registered account
github official website: https://github.com/
this is relatively simple, with reference to the official website prompts to verify the need for mailbox.
2, create a project
(1) after a successful landing, enter the personal home page, click on the button in the bottom left New repository new project (after the first project is created, then create a project in the left side of the profile click on the New button)
(2 ) then enter a project name Repository name (note the jump to a new page: name can not be repeated, the system will automatically check verification process may take a few seconds), after verification is complete, click on the button below Create repository confirm the creation of
(3) copy the link items in the project to create a good page to prepare for the next download.
3, uploading the local project to github
first step: we need to create a local repository (in fact, is a folder, if the folder has been uploaded, you do not need this step and in the right-click the folder, click git Bash Here enter the command line window).
You can right-click directly on the target location New Folder (copy this file to upload folder), you can right-click to open the Git bash command line window command to create the desktop.
:( supplemented with command-line creation steps)
1) cd directory address (to enter the target directory you want to create a new folder under)
2) LS (all files listed in the current directory, not see)
3) mkdir folder name (in current New folder directory)
4) RM -r folder name (using the command to delete a folder)
is created after a good access to the folder
Step two: enter git init this folder on the command line can become Git warehouse management, then you will find the test inside more than a .git folder, which is used to track and manage Git repository, because it is a hidden file by default, and if you can not see the settings folder (click to view , check the hidden items) and Search options.
Followed by git add. (Note that this ".", There is space, "." Represents a directory that this folder are all committed. You can also submit the file specified by git add the file name) to add files to the cache area, you can git status command to check the state now, you can not see.
Then, use the command git commit -m "This inside to write your comment" to submit the file to the local repository.
The third step: Here's connection to the remote repository (that is, connected Github)
due to transmission between local Git repository and Github repository through SSH encrypted, so you need to set the connection about: Create SSH KEY. Take a look at your C drive has no user directory .ssh directory, there are not any, look id_rsa (private, non-leakage) and id_rsa.pub (public key) these two files, there will skip to the next step, is not created by the following command
$ ssh-keygen -t rsa -C "
Step four: Log Github, find the icon in the upper right corner to open the point into the inside Settings, then select inside SSH and GPG KEYS, click New SSH key in the upper right corner, then Title inside just fill (that is, a name), and then id_rsa.pub just copy the contents inside the Key to Title the following content inside the box, and click the Add SSH key, thus completing the SSH Key encryption.
Step 5: remote repository (repository) and a local warehouse associate,
$ git the Add Remote Origin warehouse link address
Step Six: After a good correlation we can put all the contents of the local repository pushed to the remote repository (that is, Github) on a
If a remote warehouse is empty, use the command $ git push -u origin master
if not empty, for example, you check the Initialize this repository with a README with the above command will complain that this is due to the warehouse inside your newly created README file is not in the local repository directory, then we can merge the contents of the first through the following command:
$ git pull --rebase Origin Master
re-enter the command $ git push origin master (as long as the warehouse is not empty, use this command)
then appears username for ...: github enter a user name, a box will pop up, enter the password (not shown),
This completes the local project will be uploaded to the whole process of Github.
4, delete items on github
Click warehouse to be deleted, enter the page, click on the Settings menu at the top of the page and enter the new drop-down box pulled the bottom'll see Delete this repository, click on it will pop up a prompt box, to delete the input box of shells warehouse (project) name, then click delete, the page will pop up authentication password when you log on github, enter your password and click Confirm password authentication password, then delete the project a success.
5, delete the specified file on github project
because you can not delete a file on github, it is necessary to use git command to delete a file, open the project file uploading git, I want to delete a file, type git pull origin the master file on github pulled down again, then enter the command dir to view the files in the directory, and then enter the command git rm -r --cached you want to delete the file name to delete the specified files on the disk, and then enter the command git commit -m " removed *** "submit add a description, and finally enter the git push -u origin master update github repository, which is specified file will be deleted successfully.
6, warehouse update file
first or open a file in Git Bash directory and enter the command git status, then you can see the modified files have to do. Then enter the command git add -A, this command to upload all modifications, add comments to command attention at this time should be git commit -a -m "Update Notes" and enter the command file upload git push origin master -f (note upload and update the initial upload commands vary) can be.

Guess you like

Origin blog.51cto.com/14235507/2422144