Git 应用
来源:互联网 发布:花都 知乎 编辑:程序博客网 时间:2024/06/10 03:54
1. initialize new repository
1) mkdir e:/prj/repo //make directory where u want your repository in
2) cd e:/prj/repo
3) git init
4) //copy your codes directory to the directory your made just before
5) add “.gitignore" file //Ignoresomefiles, folders, need not submit
//************************************************************************//
//**************example for one .gitignore file *************************//
*.idb
*.obj
*.sbr
*.bsc
*.ilk
*.pdb
*.ncb
*.plg
*.pch
*.bak
.svn
.svn-base
//*********************************.gitignore file end*****************************************//
6) //add your code directroy to local repository
git add MyDir
7) commit change to local repository
git commit -m "
8) review the log
git log
//Information like the following will be shown
//******************************Informaion start *****************************************//
$ git log
commit 0a42a7179f1fe830f9d226856698b1dc97c150ff
Author: user <wangyilong163@163.com>
Date: Thu Jul 26 18:24:19 2012 +0800
Initlize repository for control OrderMake source
user@ASUS-E504D7A0F1 /e/prj/repo (master)
$
//******************************Information end**************************************//
9) Now the initialize procedure is complete.You can control your code in local.
If u want your codes can administ by other PC ,please refer to <<add local repository to server>>.
2. Update your changes to local repository
git commit -a -m "Change ... for ..."
3. Update your change to server repository
1) git commit -a -m "Changed ... for ..."
2) git push --repo url
Example : git push --repo /home/repo/order.git
git push --repouser@192.13.1.146:/home/repo/order.git
4. get one repository from the Git server
git clone [url]
Example : git clone /home/repo/order.git
git clone user@192.12.1.146:/home/user/order.git
Descriptor:
- <user> which is user name in server (192.12.1.146)
- /home/user/order.git is absolute path in server side。If use relative path ,write like this "git cloneuser@192.12.1.146:order.git
5. add file(s)
git add "file" //Note: After this command ,only "add" command is recorded to repository,the file is not added to repository yet.
6. delete file(s)
7. create branch
git checkout -b vga-version master //create "vga-version" branch form "master" branch
8. merge branch
1) git checkout master
2) git merge "branch" //"branch" is the branch which will be merged to "master " branch
9. tag
10. get the history version or history file
1) git log //show all versions to find out which version is you need
2) git checkout "ID of commition"
3) git checkout "file" //get file commited at last time
11. abandon your change from lastest commition
git reset --hard
12. Compare difference version in repository
1) git diff //compare difference between current edit and latest version commited to repository
2) git diff ffd98b291e0caa6c33575c1ef465eae661ce40c9 b8e7b00c02b95b320f14b625663fdecf2d63e74c
//compare two versions have been saved in repository
13. add local repository to server
a) in the PC you local repository saved in,
1) git clone --bare . "DestDir"
//"DestDir" means the direcroy u want your repository save to.
2) ssh-keygen -t rsa //generate your key and save it to file
3) //transmit your "KeyCode.pub" and "DestDir" to administrator
b) in server side
1) copy your bare repository to "/home/repo/
copy your keycode.pub to keydir of gitosis-admin repository
2) change owner of this repository
chown -R "Admin" "RepoDir"
3) modify ".gitosis.conf" file
Example :
[group OrderMake]
members = user@Coall-workStation1 root
writable = OrderMake
- Git 应用
- git 应用
- git应用
- git应用
- git 应用
- [git] git 应用
- [Git] Git初应用
- [GIT] git应用 命令总结
- git应用模式
- 版本控制 git 应用
- GIT命令行应用
- git patch应用
- git 的应用
- git应用技巧
- Git 应用参考
- git 的应用学习
- git的部分应用
- git stash 应用
- 简单易解的装饰模式
- Android中Bitmap及Drawable转换
- 计算机图形学的网络课程
- 开源的ERP:Compiere ERP
- poj1562 poj1088
- Git 应用
- 文件编译时出现multiple definition of `xxxxxx'的解决办法
- Memcache与python
- MFC对文件读取和保存的操作
- 查询本机ip和浏览器useragent的网址
- putty 编译问题
- ubuntu10.10+android 搭建Opencv
- 软件缺陷的“Bug” 软件开发的投入 软件产品由哪些部分组成 软件开发模式
- ContentType ,charset和pageEncoding的区别