Transfer from http://www.cnblogs.com/qijunjun/p/7137207.html
First, download and install Git
1, download the official Git address: https: //git-scm.com/download/win
2. After downloading, double-click the installation
3, select the installation directory
4. Select Components
5, Start Menu Settings directory name
6, choose to use the command-line environment
7, the following three steps by default, just click Next
8, the installation is complete
9, verify that the installation was successful
Return to your desktop, right-click if you see there are two words git installation was successful
Two, Git basic workflow
1, Git work area
2, add files to the repository process
Three, Git initialization and warehouse creation and manipulation
1, after Git installation requires some basic information setting
a, set the user name: git config - global user.name 'you go on github username registered';
b, set user mailboxes: git config - global user.email 'when the registered mail';
Note: This configuration will show who submitted the file on github Home
c, after configuring ok, we use the following command to see if the configuration is successful
git config --list
Note: git config --global parameters, with this parameter indicates that all of the git repository on your machine will use this configuration, of course, you can also specify a different user name and mailbox on a warehouse
2, initialize a new git repository
a, create a folder
Method One: You can right click - "click New Folder test1
Method Two: Use git New: $ mkdir test1
b, initialize git in a file (created git repository)
1. Direct Input $ cd test1
2. Click the file test1 go after - "right click select Git Bash Here-> Enter $ git int
3, add files to the repository
Method One : New index.html file to open the editor
方法二:使用git命令。$ touch '文件名',然后把文件通过$ git add '文件名'添加到暂存区,最后提交操作
4、修改仓库文件
方法一:用编辑器打开index.html进行修改
方法二:使用git命令。$ vi '文件名',然后在打开的页面上进行修改,最后提交操作
5、删除仓库文件
方法一:在编辑器中直接把要删除的文件删除掉
方法二:使用git删除:$ git rm '文件名',然后提交操作
四、Git管理远程仓库
1、使用远程仓库的目的:备份、实现代码共享集中化管理
Git远程仓库实际上就是保持在服务器上的git仓库文件
五、Git克隆操作
目的:将远程仓库(github上对应的项目)复制到本地
1、代码:git clone 仓库地址
仓库地址由来如下:
2、克隆项目
3、将本地仓库同步到git远程仓库中:git push
期间出现错误的情况有:
a、出现提交错误
解决:这是通过Git GUI进行提交时发生的错误,由 .git 文件夹中的文件被设为“只读”所致,将 .git 文件夹下的所有文件、文件夹及其子文件的只读属性去掉即可。
b、如果出现无法同步或没有权限,解决方法如下:
用户名和密码一定要和github上的一致。
c、如何解决failed to push some refs to git
在使用git 对源代码进行push到gitHub时可能会出错,信息如下
出现错误的主要原因:github中的README.md文件不在本地代码目录中
解决办法:首先使用git pull拉取github上的内容、然后再使用git push即可