Reference Blog
Http://www.xitongzhijia.net/xtjc/20150320/42297.html
Http://blog.chinaunix.net/uid-17188120-id-4650534.html
install git under 1.Ubuntu
Ubuntu14.04 LTS is already installed by default, you can use git–version to test if it is installed.
If not installed, use the command: sudo apt-get install git git-core installation git
2.SSH Certification
Under Ubuntu, use SSH to connect to the Github.com SSH service with the login name [email protected] (all GitHub users share this SSH user name).
ssh -T [email protected]
Prompt after execution:
Permission denied (publickey).
This means that we have not properly set up the public key authentication in the GitHub account.
Enter
settings->SSH and GPG keys->new SSH key
But this is not recommended.
Use GitHub's official tutorials
https://help.github.com/articles/generating-an-ssh-key/
The specific steps are:
Checking for existing SSH keys
(1) Open Terminal.
(2) Enter Ls-al ~/.ssh to see if existing SSH keys is present:
ls -al ~/.ssh#Lists the files in your .ssh directory, if they exist
(3) Check the directory listing to see if you already has a public SSH key.
GitHub is the private key and Github.pub is the public key.
Generating a new SSH key
(1) Open Terminal.
(2) Paste the text below, substituting in your GitHub email address.
ssh-keygen -t rsa -b 4096 -C "[email protected]"# Creates a new ssh key, using the provided email as a label**Generating public/private rsa key pair.**
(3) When you ' re prompted to "enter a file in which to save the key," press ENTER. This accepts the default file location.
Enter a file in which to save the key (/Users/you/.ssh/id_rsa): [Press enter]
(4) At the prompt, type a secure passphrase. For more information, see "Working with SSH key passphrases".
Enter passphrase (empty for no passphrase): [Type a passphrase]Enter same passphrase again: [Type passphrase again]
Adding your SSH key to the Ssh-agent
Before adding a new SSH key to the ssh-agent, you should has checked for existing SSH keys and generated a new SSH key.
(1) Ensure Ssh-agent is enabled:
# start the ssh-agent in the backgroundeval "$(ssh-agent -s)"Agent pid 59566
(2) Add your SSH key to the ssh-agent. If you used an existing SSH key rather than generating a new SSH key, you'll need to replace Id_rsa in the command with th E Name of your existing private key file.
$ ssh-add ~/.ssh/id_rsa
(3) ADD the SSH key to your GitHub
- Copy the SSH key to your clipboard.
If your SSH key file has a different name than the example code, modify the filename to match your current setup. When copying your key, don ' t add any newlines or whitespace.
$ sudo apt-get install xclip# Downloads and installs xclip. If you don‘t have `apt-get`, you might need to use another installer (like `yum`)$ xclip -sel clip < ~/.ssh/id_rsa.pub# Copies the contents of the id_rsa.pub file to your clipboard
Tip:if xclip isn ' t working, you can locate the hidden. SSH folder, open the file in your favorite text editor, and copy I T to your clipboard.
2.In the top right corner of any page, click your profile photo, and then click Settings.
3.In the user settings sidebar, click SSH and GPG keys
4.Click New SSH key.
5.In the "Title" field, add a descriptive label for the new key. For example, if you ' re using a-personal Mac, you might call this key "personal MacBook Air".
The key field
6.Paste your key into the "key" field.
7.Click Add SSH key.
8.Confirm the action by entering your GitHub password.
Set up account information
git config --global user.name “lukeyan”git config --global user.email [email protected]
After the setting is successful, using terminal to access GitHub with SSH commands will display a successful authentication message and exit.
ssh -T [email protected]
Prompt after execution:
Hi github! You‘ve successfully authenticated, but GitHub does not provide shell access.
You can use GIT commands to access GitHub's code warehouse directly with these steps.
3. Submit your code to GitHub
First, create a new repo on github.com, add the appropriate. Gitignore,license to the situation, and then submit the local code to GitHub
git pull #获取新版本git status #获取需要上传的文件 git add . # .表示全添加, git add README.md 表示只添加说明文件git commit -m "add new files" # a commitgit remote add origin [email protected]:yourgithubname/yourrepositorynamegit push -u origin master
Attach a picture that is useful:
4. Establish branch and pull requests
To create a new branch
(1) Go to your new repository e.g. Hello-world.
(2) Click the drop at the top of the file list that says Branch:master.
(3) Type a branch name, Readme-edits, into the new branch text box.
(4) Select the Blue Create branch box or hit "Enter" on your keyboard.
Now there are both branches, master and Readme-edits. They look exactly the same, and not for long! Next We ll add our changes to the new branch.
Make some changes to the new branch
Click the readme.md file.
Click the pencil icon in the upper right corner of the file view to edit.
In the editor, write a bit about yourself.
Write A COMMIT message that describes your changes.
Click Commit Changes button.
Open a pull Request
Pull Request 是什么意思百度知道:有一个仓库,叫Repo A。你如果要往里贡献代码,首先要Fork这个Repo,于是在你的Github账号下有了一个Repo A2,。然后你在这个A2下工作,Commit,push等。然后你希望原始仓库Repo A合并你的工作,你可以在Github上发起一个Pull Request,意思是请求Repo A的所有者从你的A2合并分支。如果被审核通过并正式合并,这样你就为项目A做贡献了
Click the Pull Request tab and then from the Pull Request page, click on the green New Pull request button.
Select the branch made, Readme-edits, to compare with Master (the original).
Look over your changes in the diffs on the Compare page, make sure they ' re what do you want to submit.
When your ' re satisfied that these is the changes you want to submit, click the Big Green Create pull Request button.
Give your pull request a title and write a brief description of your changes.
When you ' re do with your message, click the Create pull request!
Merge your Pull Request
In this final step, it's time to bring your changes together–merging your readme-edits branch into the master branch.
Click the green Merge Pull request button to Merge the changes into master.
Click Confirm Merge.
Go ahead and delete the branch, since its changes has been incorporated, with the Delete branch button in the Purple box.
*
5. Cloning a project from GitHub to a local
*
Step one: Go to a warehouse in GitHub and copy the "HTTPS clone url" to the right
Step two: Go back to the directory you want to store, use the command "Git clone https://github.com/chenguolin/scrapy.git", the red URL is just an example
Step three: If the local version is not up-to-date, you can use the command "Git fetch origin", Origin is the local repository
Fourth Step: Merge the updated content into the local branch, you can use the command "git merge Origin/master"
If you do not want to manually merge, then you can use: Git pull < local repository > master//This command can be pulled to the latest version and automatically merged
*
6 GitHub's branch management
*
Create
1 Create a local branch: GIT branch < new branch name >
2 Synchronizing a local branch to GitHub: Git push < local repository name > < new branch name >
3 Switch to the newly established branch: Git checkout < new branch name >
4 Add a new remote end to your branch: Git remote add < remote End name > < address >
5 View the current warehouse has several branches: Git branch
Delete
1 Delete a branch from the Local: git branch-d < branch name >
2 Sync to github Delete this branch: git push < local repository name >:
*
7 Common errors
*
1 If an error is error:repository not found.fatal:The remote end hung up unexpectedly is the wrong URL link for your origin, it could be a creation error or this [Emai L protected]:xxx/new-project.git URL specified incorrectly. Re-create.
gedit ./git/config
Remove the [Remote origin] section from the file!
Re-initialize
git init
Install git under Ubuntu and upload the code to GitHub