What is github
GitHub is a project for open source and proprietary software hosting platform, because as the sole support only git repository hosting format, named GitHub.
GitHub on April 10, 2008 formally launched, in addition to the Git repository hosting and basic Web management interface, also offer a subscription, discussion groups, text rendering, online file editor, collaborative map (report), code snippets share ( Gist) and other functions. At present, it has over 3.5 million registered users, the number of hosted version is also very much, many of whom are well-known open source projects Ruby on Rails, jQuery, python and so on.
We can put our local code pushed to github above, on if you want to push to github, we need to have our own github account, but also to build a warehouse
Creating a warehouse
Now, after we all have our github account, and create a warehouse jump page as follows
Here I divided it into two areas, the first area is not your local version control, command execution
The second is that you already have a local file, and perform version control via git, use the following command to push on github.
The origin of which we give back the address's nickname, you can customize
Pushed to github
# Aliases to a remote repository git remote add origin remote warehouse address # Handover branch git push -u origin branch name
We've got a local folder, and has been managed git up, so we execute the second command, I have here the choice is https
# git remote add origin https://github.com/liuzouzou/git_demo.git # git push -u origin master Enumerating objects: 22, done. Counting objects: 100% (22/22), done. Delta compression using up to 4 threads. Compressing objects: 100% (21/21), done. Writing objects: 100% (22/22), 2.33 KiB | 476.00 KiB/s, done. Total 22 (delta 6), reused 0 (delta 0) remote: Resolving deltas: 100% (6/6), done. To https://github.com/liuzouzou/git_demo.git * [new branch] master -> master Branch 'master' set up to track remote branch 'master' from 'origin'.
So we put our code pushed on github, refresh can see our code already exists
But this push up only master, before we created two branches, one dev branch, a branch of a bug, bug our branches are removed
If we need to dev also push up, you can execute the following command
# git push -u origin dev Total 0 (delta 0), reused 0 (delta 0) remote: remote: Create a pull request for 'dev' on GitHub by visiting: remote: https://github.com/liuzouzou/git_demo/pull/new/dev remote: To https://github.com/liuzouzou/git_demo.git * [new branch] dev -> dev
So that our dev branch will also push up the
Pulling the code from github
Since we pushed to the code on github, we have developed from another machine, this time we can pull down from the github
# Cloning a remote repository Code
git clone remote repository address (internal realized git remote add origin remote repository address)
# git clone https://github.com/liuzouzou/git_demo.git Cloning into 'git_demo'... remote: Enumerating objects: 22, done. remote: Counting objects: 100% (22/22), done. remote: Compressing objects: 100% (15/15), done. remote: Total 22 (delta 6), reused 22 (delta 6), pack-reused 0 Unpacking objects: 100% (22/22), done.
So we put the code on github pull down, there is also a corresponding version, although using git branch see the dev branch, in fact, exist, we can switch directly to the dev branch in
git pull
We use the above git clone pull down the code from a remote repository, if the next time we get the latest code from github, need to clone it? The answer is certainly not, and only when local git clone is not the first time it needs to get, if there are already some local code, you do not need to use the git clone with git pull on it
# Git pull pulling Origin master master code # # Git pull pulling Origin dev dev code
pull origin dev equivalent to the following two lines of code above git
# git fetch origin dev # git merge origin/dev
When we use git pull origin dev it is the remote repository code to pull the local workspace
Execute git fetch origin dev remote warehouse is to pull the code to a local repository
Execute git merge origin / dev is the local version of the code library pulling into the local workspace
git tag
The version number is displayed before we submitted to us are git automatically generated, as follows
Before did not tag, Tags and release on github are empty
Create a tag information locally
# Git Tag version1 -m 'version1 version of' -a
The local tag information pushed to the remote repository
Use git push origin --tags pushed to the remote repository
# git push origin --tags
Enumerating objects: 1, done. Counting objects: 100% (1/1), done. Writing objects: 100% (1/1), 166 bytes | 166.00 KiB/s, done. Total 1 (delta 0), reused 0 (delta 0) To https://github.com/liuzouzou/git_demo.git * [new tag] version1 -> version1
And then go on github View
After the establishment of a tag, you can download the zip or tar package in the release in
Delete the local tag
# git tag -d version1
Update the local version of the tag information
# git pull origin --tags
Tag switching
# git checkout version1
Download the code specified tag
# Git clone -b version1 address