linux git 环境安装配置

win8承载了微软太多的期望,希望以此来一统桌面PC和移动手机市场,也弄出了很多的动静和噱头。正好同事下载了win8RC于是就用虚拟机VMware尝尝鲜。

安装中并没有让我产生第一次装win7时的那种震撼和惊艳,进去了是早有耳闻的方块元素,默认壁纸也没有win7的耐看。(win7默认壁纸到现在也没换过)

试用了30分钟实在没有用下去的想法,UI做如此大的变革实在是一件风险极大的事情,可以说是一种强X用户习惯和体验之举,比如没有开始菜单就让我极其反感。

强烈感觉NOKIA这么一个伟大的手机公司被微软坑了,就metro这德性,NOKIA振兴的那天估计是很难看到了。

扯远了,有了VMware我也顺便装了一个最新的ubuntu 12.04,第一感觉又是习惯被强X了,你大爷的Unity,做的都没360桌面好看,你大爷的要求我换那些用习惯了工具,搜了网上一坨人也在抱怨,解决方案是自己安装Gnome,可是只能装Gnome3,但这货菜单条又缺少网络链接和登出选项,不想折腾了,果断装回了Ubuntu10.10.(我同事也因为类似原因改用linuxMint了)。重配Git环境遇到了一些问题,稍作记录吧。

说明:以下内容绝大部分来自于:https://github.com/。

1,下载git

$ apt-get install git-core

2,配置个人信息(非必须)。

git config --global user.name "Your Name Here"git config --global user.email "your_email@youremail.com"

3,设置密码缓存时间

/**To use this option, you need to tur*n on the credential helper so that git*will save your password in memory f*or some time:*/git config --global credential.helper cache# Set git to use the credential memory cache//By default git will cache your password for 15 minutes. You can change this if you like.git config --global credential.helper 'cache --timeout=3600'# Set the cache to timeout after 1 hour (setting is in seconds)

4,配置远程github库ssh密码

First, we need to check for existing ssh keys on your computer. Open up Git Bash and run:cd ~/.ssh# Checks to see if there is a directory named ".ssh" in your user directorySince there is already an SSH directory you'll want to back the old one up and remove it:ls# Lists all the subdirectories in the current directory# config  id_rsa  id_rsa.pub  known_hostsmkdir key_backup# Makes a subdirectory called "key_backup" in the current directorycp id_rsa* key_backup# Copies the id_rsa keypair into key_backuprm id_rsa*# Deletes the id_rsa keypairTo generate a new SSH key, enter the code below. We want the default settings so when asked to enter a file in which to save the key, just press enter. ssh-keygen -t rsa -C "your_email@youremail.com"# Creates a new ssh key using the provided email# Generating public/private rsa key pair.# Enter file in which to save the key (/c/Users/you/.ssh/id_rsa): [Press enter]Now you need to enter a passphrase.Why do passphrases matter?# Enter passphrase (empty for no passphrase): [Type a passphrase]# Enter same passphrase again: [Type passphrase again]Which should give you something like this: # Your identification has been saved in /c/Users/you/.ssh/id_rsa.# Your public key has been saved in /c/Users/you/.ssh/id_rsa.pub.# The key fingerprint is:# 01:0f:f4:3b:ca:85:d6:17:a1:7d:f0:68:9d:f0:a2:db your_email@youremail.comStep 4: Add your SSH key to GitHubRun the following code to copy the key to your clipboard.clip < ~/.ssh/id_rsa.pub# Copies the contents of the id_rsa.pub file to your clipboardBe warned: it is important to copy the key exactly without adding newlines or whitespace. Thankfully the clip command makes it easy to perform this setup perfectly.Go to your Account SettingsClick "SSH Keys" in the left sidebarClick "Add SSH key"Paste your key into the "Key" fieldClick "Add key"Confirm the action by entering your GitHub password

5,建立一个本地代码库

Step 1: Create the README fileIn the prompt, type the following code:mkdir ~/Hello-World# Creates a directory for your project called "Hello-World" in your user directorycd ~/Hello-World# Changes the current working directory to your newly created directorygit init# Sets up the necessary Git files# Initialized empty Git repository in /Users/you/Hello-World/.git/touch README# Creates a file called "README" in your Hello-World directoryStep 2: Commit your READMENow that you have your README set up, it's time to commit it. A commit is essentially a snapshot of all the files in your project at a particular point in time. In the prompt, type the following code:More about commitsgit add README# Stages your README file, adding it to the list of files to be committedgit commit -m 'first commit'# Commits your files, adding the message "first commit"Step 3: Push your commitSo far everything you've done has been in your local repository, meaning you still haven't done anything on GitHub yet. To connect your local repository to your GitHub account, you will need to set a remote for your repo and push your commits to it:More about remotesgit remote add origin https://github.com/username/Hello-World.git# Creates a remote named "origin" pointing at your GitHub repogit push origin master# Sends your commits in the "master" branch to GitHub

6,git 命令无法自动补全解决方法:

参见以下博客:ClickMe!

补充:因为VMware是要收费的,费用也很高,所以换开源的virtualBox了,挺好用的,就是分辨率上遇到些问题,装上拓展包后就基本解决了:

sudo apt-get install virtualbox-ose-guest-utils virtualbox-ose-guest-x11 virtualbox-ose-guest-dkms

活在当下,别在怀念过去或者憧憬未来中浪费掉你现在的生活。

linux git 环境安装配置

相关文章:

你感兴趣的文章:

标签云: