git简单使用方法
来源:互联网 发布:java 高性能服务器 编辑:程序博客网 时间:2024/06/05 16:17
摘要
目标是看了这边文章能够满足最基本的git使用需求。整个文章的远程git库以git.osc为例。
初始化
安装好后,鼠标右键点git bash here,会出来命令行界面。
首先到~目录
root@host MINGW64 /d/$ cdroot@host MINGW64 ~$
用户名和邮箱
必须有,远程git库通过这个确定是谁提交的代码。
git config --global user.name "username"
git config --global user.email "email"
设置SSH
项目链接分为 https 或者 ssh
- 如果是https,每次提交代码到远程git库需要输入osc的用户名和密码,比较麻烦。
- 如果是ssh,需要生成一份rsa密钥,把私钥保存在本地~/.ssh目录,公钥存在osc账号中。这样每次push,pull代码不需要输入密码,非常方便。
ssh生成密钥
ssh-keygen -t rsa
,按三个回车,密码为空。
看看生成结果。
root@host MINGW64 ~$ cd .ssh/root@host MINGW64 ~/.ssh$ lsid_rsa id_rsa.pub known_hostsroot@host MINGW64 ~/.ssh$ cat id_rsa.pubssh-rsa XXX.....XXX levonhe@163.com
osc中添加公钥
路径是 个人资料 -> ssh公钥
代码维护
创建本地代码库
root@host MINGW64 /d$ mkdir projectAroot@host MINGW64 /d$ cd projectA/root@host MINGW64 /d/projectA$ git initInitialized empty Git repository in D:/projectA/.git/
关联远程代码库
root@host MINGW64 /d/projectA (master)$ git remote add oschina git@git.oschina.net:levonhe/JiSenMall.gitroot@host MINGW64 /d/projectA (master)$ git remote -voschina git@git.oschina.net:root/projectA.git (fetch)oschina git@git.oschina.net:root/projectA.git (push)
从远程库下载代码
root@host MINGW64 /d/projectA (master)$ git pull oschinaremote: Counting objects: 8268, done.remote: Compressing objects: 100% (5808/5808), done.remote: Total 8268 (delta 2480), reused 7970 (delta 2284)Receiving objects: 100% (8268/8268), 123.92 MiB | 586.00 KiB/s, done.Resolving deltas: 100% (2480/2480), done.From git.oschina.net:levonhe/projectA * [new branch] branch1 -> oschina/branch1 * [new branch] master -> oschina/master * [new tag] v0.1.1 -> v0.1.1You asked to pull from the remote 'oschina', but did not specifya branch. Because this is not the default configured remotefor your current branch, you must specify a branch on the command line.
提交代码流程
git add .
->git commit
->git push oschina $branch
branch是分支名字。如果代码有冲突,
git fetch
->git merge
-> 修改冲突文件 ->git add .
->git commit
->git push
0 0
- git 简单使用方法
- git简单命令使用方法
- git简单使用方法
- git简单使用方法
- Git 简单使用方法
- git简单使用方法
- 简单的git使用方法
- git 简单的使用方法
- 【Git】简单使用方法
- Git的简单使用方法
- git命令的简单使用方法
- github简单使用方法【使用git bash】
- Git使用方法
- git使用方法
- git使用方法
- git 使用方法
- Git使用方法
- Git使用方法
- CodeForces 337C 找规律 ,等比数列求和
- JavaScript脚本引擎Rhino
- 四元数矩阵
- 关于获取设备内容的几种方式和区别
- 安装两次ORACLE客户端,PL-SQL登录报错 ORA-12154
- git简单使用方法
- switch的语法
- 四元数转欧拉角
- Parse教程一(使用parse向你的Android程序推送消息)
- AndroidWheel 省市区三级联动(高仿IOS版本)
- java学习笔记.04——线程池
- do-while的语法
- for循环
- Android手机适配