Git new computer build and use from the start

Source: Internet
Author: User

Here's how I'm going to build the GIT environment one step after I get my new Mac.
First let's open the terminal


Enter Git on the terminal
If you are stuck to the following results that you do not have a git installed, go to install.
The program ' git ' was currently not installed. You can install it by typing:
sudo apt-get install git

If you happen to be an iOS developer and have Xcode installed on your Mac, the new Xcode is installed by default with Git

If you do not have xcode to install a homebrew, and then install Git through homebrew, refer to the homebrew documentation: http://brew.sh/.

Execute commands after installation

$ "Your Name"$ "[email protected]"

After Setup, look at the git configuration

$gitconfig--list

Next Configure SSH Key
1. See if SSH key is already available

cd ~/.ssh

If it does not exist prompt: No such file or directory
If it already exists, go to the ~/.ssh directory, back up the current key (. SSH directory), and then delete it.
Back up existing keys

$ mkdir key_backup$ mv id_rsa* key_backup

. Generate SSH Key

$ ssh-keygen-t-C"[email protected]"

In the middle there will be three prompt input, respectively, the key to save the directory, the private key password, the private key to confirm the password
These three times can be directly hit enter.

. View Id_rsa.pub

$ vim  

Copy the key inside,
Back to Gitub, enter the account Settings (accounts configuration), the left to choose SSH keys,new ssh key,title write a good for you to distinguish, paste on your computer generated key ADD SSH key, OK.


Verify that the success is successful.

$ ssh -T git@github.com

If this is the first time you are prompted for continue, enter Yes to see:
You've successfully authenticated, but GitHub does not provide shell access.
Indicates successful connection to Github,github configuration ssh succeeded

Now that git is installed and configured,
Next use Git

Open Terminal:
1. There are already documents entering

cd‘your profile‘

2. No files Yet, create a new folder

$ ‘your profile‘ 进入你想创建文件夹的地方$ ‘profile name‘

Create Git

$ git init

New file to add file to warehouse

add readme.md

A project commit is synchronized to the local library

$ "wrote a readme file"

To create a remote library:

Associating remote libraries

add origin [email protected].com:WilonChen/FrameWorkMainProgram.git

If an error
Tip error Message: Fatal:remote origin already exists.
The solution is as follows:
1. Enter first

$ git remote rm origin

2. In the input

add origin [email protected].com:WilonChen/FrameWorkMainProgram.git

You won't get an error!
Here wilonchen......git is all my content you need to replace it with your own git

and pull it down.

$ git pull

Push

$ git push

If you run into push without specifying branch
You need to specify branch
Here, I'm going to push everything to master.

--set-upstream master origin/master

If you see the 100% picture, you will succeed!

Order of execution after Git clone

add .
$ "wrote a readme file"
$ git push

Git new computer build and use from the start

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.