Git简介
Git是一个免费的、分布式的版本控制工具,或是一个强调了速度快的源代码管理工具。每一个Git的工作目录都是一个完全独立的代码库,并拥有完整的历史记录和版本追踪能力,不依赖于网络和中心服务器。
Git 在管理项目时,在本地会有三个工作区域:Git 的本地数据目录,工作目录以及暂存区域。如下图所示:
因此对于任何一个文件,在 Git 内都只有三种状态:已提交(committed),已修改(modified)和已暂存(staged)。
安装及配置Git
sudo apt-get install git git-core
首先去https:/// 注册一个账户,当然是free and opensource的用户了。
mkdir ~/git
初始化两个参数:
git config --global = "username" git config --global user.email = "your_email@example.com"
因为本机是通过ssh链接github的,所以先创建ssh密钥。
cd ~/.ssh
提示没有文件或者目录的话说明本机还没有创建过,继续执行
ssh-keygen -t rsa -C "your_email@example.com"
一路Enter,在根目录下面就会生产.ssh文件夹(隐藏,查看隐藏文件夹的话按Ctrl+H),里面有生产的密钥文件。
ssh -T git@
成功连接的结果就想这样:
Agent admitted failure to sign using the key. Permission denied (publickey).
执行
ssh-add再进行连接就没问题了。
使用git
git clone https:///SimonVT/android-menudrawer.git
会自动下载整个工程到当前的目录。
mkdir ~/git/repos cd ~/git/repos git clone git@:***/***.git
执行完毕后,repos文件夹下就拷贝好了github上的项目。
git add . //往暂存区域添加已添加和修改的文件,不处理删除的文件 git status //比较本地数据目录与暂存区域的变化 git commit -m "commit directions" //提到代码到本地数据目录,并添加提交说明
git pull //更新代码 根据提示修改冲突文件中的代码 git add . git commit -m "commit directions"
git push
Create a new repository on the command line
touch README.md
git init
git add README.md
git commit -m "first commit"
git remote add origin https:///user_name/repository_name.git
git push -u origin master
want to merge with, and 'branch.master.merge' in
your configuration file does not tell me, either. Please
specify which branch you want to use on the command line and
try again (e.g. 'git pull <repository> <refspec>').
See git-pull(1) for details.
git config branch.master.remote origin
git config branch.master.merge refs/heads/master
git config --global credential.helper 'cache --timeout 3600'
在Eclipse中整合git
git remote add origin https:///SilangQuan/LinearCompiler.git
再执行
git push -f
















