Reprinted from: http://www.faceye.net/search/77573.html
One: Create repositories
1: First create an account under GitHub. This doesn't have to be said, then create a repositories.
2: Then install git-related stuff under Ubuntu:
1 |
sudo apt-get install Git-core Git-gui git-doc-y |
3: Create an SSH key locally in Ubuntu:
1 |
Ssh-keygen-t rsa-c "[Email protected]" |
You will be prompted in the user home directory. SSH subfolder to generate a key, and then ask for the password and so on, and finally the following will be prompted:
It will generate Id_rsa.pub and id_rsa two files in the/~/home/.ssh/folder. Where Id_rsa is the private key, save exists locally, and id_rsa.pub is the public key.
Then paste the contents of the public key into the location of your GitHub account in the SSH keys. Note Be careful not to copy to a space.
4: Test whether SSH is connected properly (you may need to v[p\n]) if there is any possibility of g[f]\w on GitHub website.
1 |
ssh-t [email protected] |
Note [email protected] cannot be changed, it is the address of GitHub official website. After running, you will be prompted to accept the new Sshkey request, enter ' Yes ', and then a request to access the ID_RSA private key request We just established, then enter the password for the private key. Success is indicated by the following prompt:
1 |
Hi justchen! You've successfully authenticated, but GitHub does not provide shell access. |
5: The next most important step is to configure the GitHub environment.
To initialize the GIT project directory for the first time, set up the project directory, then go to the directory and run the following command to initialize it.
12345678910111213141516171819 |
git config--global user.email git config--global user.name git init# GitHub automatically reads your readme content and displays it in the project profile, so first create the Readmetouch RE adme# Add the README to index git add readme# commit to the repository git commit-m ' first commit ' #-M followed by a string representing the change of the commit description # run git add xxx or git commit-m ' xxx ' did not upload the file to the GitHub server, just updated the version in Git locally # add GitHub repo to remote Repogit add origin [email protected]:/test.git# Push and sync the current commit state to GitHub, need to access your SSH private key and enter the password Git push origin master# the above command is to commit git as the original master, need access to your SSH private key and enter the password # If you have created git remote add Origin xx Once, just run the following line when the code is updated to GIT push Origin master |
Some common git commands are included.
12345678910111213141516171819202122232425262728293031323334 |
# Create a repository git init# each time you make a change, you can save the changes to the stage (snapshot/index) git add # Modify a large number of files and use the following command to bulk save git Add. # Commit the contents of the snapshot/index to the repository using commit git Commit-m "MSG" # can also be git add and git commit with a command to complete git commit-a-M "MSG" # to the local git file with GitHub (remote) sync git push# will github (remote) git files and Local synchronization (that is, updating the local side of repo) git pull# For example, the pull instruction actually contains the fetch (the change is copied back) and the merge (merge) operation Git pulling Git://github.com/tom/test.git # Another version of the control system branch function is also very interesting, if you modify the bug, but also add new features, you can fork out a branch: A special fix bug, a dedicated to add new features, wait until the stability and then merge merged git branch Bug_fix # Establish branch, named Bug_fixgit Checkout bug_fix # Switch to bug_fixgit checkout master #切换到主要的repogit merge Bug_fix #把bug_ Fix this branch and now branch Merge # If you have remote branch, want to view and Checkoutgit branch-r # view remote branchgit checkout-b bug_fix_local bug_fix_ Remote #把本地端切换为远程的bug_fix_remote Branch and named Bug_fix_local # There are other tools that can see the repo status git log #可以查看每次commit的改变git diff # Can see the contents of the last change, plus the parameters can see other changes and compare git show #可以看某次的变更 # If you want to know the status of the current working tree, you can enter GIT status |
[Git/github] Ubuntu 14.0 under Github Configuration