ubuntu installation configuration github

Use of github under ubuntu
March 16, 2012 / network technology / No Comments

One: Create Repositories
1: First create an account under github. Needless to say, 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 a ssh key locally on ubuntu:

1
ssh-keygen -t rsa -C "[email protected]"

You will be prompted to generate a key in the .ssh subfolder in the user's home directory, and then ask to enter the password, etc., and finally you will get the following prompt: Among them, id_rsa will be generated in the /~/home/.ssh/ folder. pub and id_rsa are two files. id_rsa is the private key, saved locally, id_rsa.pub is the public key. Then paste the contents of the public key to the SSH Public Keys location in your github account. Be careful not to copy into spaces. 4: Test whether the ssh connection is normal (due to the possibility of being G[F]\W on the github official website, you may need V[P\N]).





1
ssh -T git@github.com

Note that [email protected] cannot be changed, that is the address of the official github website. After running, it will prompt whether to accept the new sshkey request, enter'yes', and then there will be a request to access the id_rsa private key request we just created. At this time Enter the password of the private key, if you get the following prompt, it means success:

1
Hi justchen! You've successfully authenticated, but GitHub does not provide shell access.

5: The next step is the most important link, configuring the github environment. If
you initialize the git project directory for the first time, create the project directory, then enter the directory and run the following commands in turn to initialize.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
git config  --global user.email 
 git config  --global user.name 
 git init 
# github will automatically read your README content and display it in the project introduction, so first create a README 
touch README
 # Add README to index 
git add README
 # Submit to the repository 
git commit  -m'first  commit' 
# The string after -m indicates the submission instructions for this change 
#After running git add xxx or git commit -m'xxx', the file is not uploaded to github server, just git locally updated code version 
# of the github repo joined the remote repo 
git remote the Add Origin git @ github.com: / test.git
 # commit the current state of push and sync to github above, need access Your ssh private key and enter the password 
git push origin master
#The above command is to submit git as the original master, you need to access your ssh private key and enter the password 
 
# If you have created git remote add origin xx once, but when the code is updated, just run the following line. 
git push origin master

Attach some commonly used git commands.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# Create a repository 
git init 
# After each modification, you can first save the modification to the stage (snapshot/index) 
git add  
# If a large number of files are modified, use the following command to batch save them into 
git add .
 # Use commit to Submit the content in the snapshot/index to the repository 
git commit  -m  "msg" 
# You can also use git add and git commit to complete 
git commit  -a  -m  "msg" 
# Connect the local git file to github (remote ) On the synchronization 
git push 
# 
Synchronize the github (remote) git file with the local (that is, update the local repo) git pull 
# For example, the pull instruction actually includes fetch (copy changes back) and merge (merge) operations 
git pull git: // github.com / tom / test.git # In addition, the branch function of the version control system is also very interesting. If you want to modify the bug at the same time and add new functions, you can fork a branch: one dedicated to fixing bugs, one dedicated Add new features, wait until stable, then merge to merge git branch
 

bug_fix # Establish a branch, named bug_fix 
git checkout bug_fix # Switch to bug_fix 
git checkout master # Switch to the main repo 
git merge bug_fix # Combine the bug_fix branch with the current branch 
 
# If there is a remote branch, you want to check and checkout 
git branch  -r  # View the remote branch 
git checkout  -b bug_fix_local bug_fix_remote #Switch the local side to the remote bug_fix_remote branch and name it bug_fix_local 
 
# There are other tools that can view the status of the repo 
git log  # You can view the change of each commit 
git diff  # You can view the last changed content, add parameters to see other changes and compare with each other 
git show  #
 
可以看某次的改# If you want to know the current working tree status, you can enter 
git status

Guess you like

Origin blog.csdn.net/tgxblue/article/details/9620455