Build a git environment under Linux
1. Create a GitHub account, https://github.com
2, Linux create SSH key:
[Plain]View Plaincopy
- Ssh-keygen # #一直默认就可以了
3. Add the public key to the GitHub account information accounts settings->ssh key
4. Test verification is successful.
[Plain]View Plaincopy
- ssh-t [email protected]
- Hi someone! You've successfully authenticated, but GitHub does not provide shell access.
Sync GitHub to Local
1. Copy the project to Local:
[Plain]View Plaincopy
- git clone git://github.com:xxxx/test.git # #以gitreadonly方式克隆到本地, can only read
- git clone [email protected]:xxx/test.git # #以SSH方式克隆到本地, can read and write
- git clone https://github.com/xxx/test.git # #以https方式克隆到本地, can read and write
- git fetch [email protected]:xxx/xxx.git # #获取到本地但不合并
- git pull [email protected]:xxx/xxx.git # #获取并合并内容到本地
Submit a project locally to GitHub
1. Local Configuration
[Plain]View Plaincopy
- git config--global user.name ' Onovps '
- git config--global user.email ' [email protected] ' #全局联系方式, optional
2. Create a new Git project and submit it to GitHub.
[Plain]View Plaincopy
- mkdir TestDir & CD TestDir
- Touch readme.md
- Git init #初始化一个本地库
- git add readme.md #添加文件到本地仓库
- git rm readme.md #本地倒库内删除
- Git commit-m "First commit" #提交到本地库并备注, at which time the change is still local.
- Git commit-a # #自动更新变化的文件, a can be understood as auto
- git remote add xxx [email protected]:xxx/xxx.git #增加一个远程服务器的别名.
- git remote rm XXX # #删除远程版本库的别名
- git push-u remotename master #将本地文件提交到Github的remoname版本库中. The local changes were updated to the GitHub service at this time.
Branch version operation
1. Creating and Merging branches
[Plain]View Plaincopy
- Git branch #显示当前分支是master
- Git branch new-feature #创建分支
- git checkout new-feature #切换到新分支
- VI page_cache.inc.php
- git add page_cache.inc.php
- Git commit-a-M "added initial version of page cache"
- Git push Origin new-feature # #把分支提交到远程服务器, simply commits the branching structure and content to the remote, and does not occur with the trunk merging behavior.
2, if the New-feature branch mature, it is necessary to merge into Master
[Plain]View Plaincopy
- git checkout Master #切换到新主干
- git merge New-feature # #把分支合并到主干
- Git branch #显示当前分支是master
- git push #此时主干中也合并了new-feature code
git commands use the mind map : "Very material"
Http://www.cnblogs.com/1-2-3/archive/2010/07/18/git-commands.html
Using GIT commands and GitHub projects under Linux