使用Git和远程代码库
来自:http://blog.jobbole.com/53573/
工作步骤
- 创建一个远程的空代码库(在BitBucket上)
- 在本地代码库添加一个项目
- 在分支上开发新功能
- a) 保留新功能 或者 b) 丢弃它们
- 也许,回到某个早先的时间点
- 将本地代码库推送到远程代码库
- 在另一台机器上取得远程代码库
安装Git
git clone https:
//github
.com
/git/git
创建一个远程代码库
设置Git
git config --global user.name
"your_username"
git config --global user.email your_email@domain.com
git config --global push.default simple
创建一个本地代码库
cd
~
/workspace/my_site/
cd
c:\workspace\my_site
git init
加载(Stage)文件
git add .
git add my_file, my_other_file
提交文件
git commit -m
"initial commit"
git status
创建分支
git checkout -b new_feature
git branch new_featuregit checkout new_feature
git branch
合并分支
git add .git commit -m
"adds my new feature"
git checkout master
git merge new_feature
丢弃分支
git add .git commit -m
"feature to be discarded"
git checkout master
删除一个分支
git branch -d new_feature
git branch -D new_feature
回滚到之前的提交状态
git log
commit ca82a6dff817ec66f44342007202690a93763949Author: your_username your_email@domain.comDate: Mon Nov 4 12:52:11 2013 -0700 changes the frontpage layout
commit 085bb3bcb608e1e8451d4b2432f8ecbe6306e7e7Author: your_username your_email@domain.comDate: Mon Nov 4 11:40:33 2013 -0700 adds my new feature
commit a11bef06a3f659402fe7563abf99ad00de2209e6Author: your_username your_email@domain.comDate: Mon Nov 4 10:37:28 2013 -0700 initial commit
git checkout 085bb3bcb
git checkout -b my_previous_version 085bb3bcb
推送到远程代码库
git remote add origin https:
//your_username
@bitbucket.org
/your_username/name_of_remote_repository
.git
git push origin master
取得远程代码库的一份本地拷贝
git clone https:
//your_username
@bitbucket.org
/your_username/name_of_remote_repository
.git
git pull origin master
别名
git config --global
alias
.c
'commit -m'
git config --global
alias
.c
'commit -m'
git config --global
alias
.co
'checkout'
git config --global
alias
.cob
'checkout -b'
git config --global
alias
.br
'branch'
git config --global
alias
.m
'merge'
git config --global
alias
.a
'add .'
git config --global
alias
.s
'status'
git config --global
alias
.dbr
'branch -d'
进一步
使用Git和远程代码库相关推荐
- git 删除本地分支和远程分支、本地代码回滚和远程代码库回滚
[git 删除本地分支] git branch -D br [git 删除远程分支] git push origin :br (origin 后面有空格) git代码库回滚: 指的是将代码库某分支退 ...
- git远程代码回滚_【GIT】git 删除本地分支和远程分支、本地代码回滚和远程代码库回滚...
git branch -D br [git 删除远程分支] git push origin :br (origin 后面有空格) git代码库回滚: 指的是将代码库某分支退回到以前的某个commit ...
- 使用git向远程厂库提交代码时rejcted错误
在使用git向远程厂库提交代码时: 有的小朋友会出现 Push rejected: Push to origin/master was rejected 出现这样的问题应该是本地厂库和远程厂库没有管理 ...
- 本地连接远程代码库——生成公钥SSH Key(Linux版)
一.问题描述 在linux服务器上连接远程gitlab代码库,报错Please make sure you have the correct access rights and the reposit ...
- Git建立远程代码仓库和本地代码仓库
Git建立远程代码仓库和本地代码仓库 使用Git管理代码,需要有两个仓库.一个是远程代码仓库,一个是本地代码仓库. 远程仓库是用来托管代码的平台,比如说Github,GitLab,Gerrit,码云G ...
- eclipse git 取远程代码_【JAVA】Eclipse中使用git进行pull远程代码
当使用eclipse或者MyEclipse进行pull远程代码的时候,或者github的代码的时候报如下错误代码: 代表我们没有配置我们的Git地址,这里我教大家配置一下.首先下面是错误代码: The ...
- git更新远程代码到本地仓库的命令
方式一 (远程代码下载到本地新建分支:对比区别后在合并) 查看远程分支 git remote -v $ git remote -v origin https://github.com/shangshe ...
- git 更新远程代码到本地仓库
git fetch 的简单用法:更新远程代码到本地仓库 方式一 (远程代码直接下载合并到本地) 1. 查看远程仓库 $ git remote -v eoecn https://github.com/e ...
- Git提交远程代码时出现remote Incorrect username or password ( access token )
在使用Git进行项目代码提交的最后一步操作的时候,出现了一个问题,remote: Incorrect username or password ( access token ) git出错截图: 造成 ...
- Intelij IDEA管理git之远程代码冲突解决方案
本博文所说的代码冲突是指:项目托管在git服务器上面,两个人同时修改了同一个文件导致的冲突问题. 问题解决:工具:intelij IDEA 2016.2 为了构造一个冲突的环境用于书写这篇博客,本人采 ...
最新文章
- C#中Base64之编码,解码方法
- leetcode 226. Invert Binary Tree
- DB2中导出数据库的所有DDL脚本
- 洛谷 P2731 骑马修栅栏 Riding the Fences
- java集合(4)-Set集合
- qt 不显示 mysql 数据表中的内容_qt 数据库操作总结
- 2014-08-26 遇到的小问题
- win7硬盘安装工具_如何重装电脑安装Win7 系统?最简单,最便捷的办法,值得收藏...
- 请详细描述listview与gridview的异同点_一建考试中,实在不会的怎么办?教你从题目中获取得分点!...
- 进程线程的调度阻塞唤醒
- 四则运算2扩展---c++
- -webkit-filter
- 那些让人忍不住推荐的思维导图软件
- java随机生成中文名、性别、手机号、住址、email
- max函数的线性化方法
- uni-app uView UI框架 下载安装教程
- 这个 api 管理工具悄悄开源了,快来看看
- git官网 中文教程 使用手册 说明书
- css实现文字或者div盒子水平垂直居中的方法
- JS中对象用点(.)和方括号([])的区别
热门文章
- paip.终端服务器超出了最大允许连接数的解决
- paip.账务系统的安全性
- VSCODE: 快速生成html框架
- (转)投资很难赚到你不信的那份钱︱投资道
- Julia: 引用、copy与数组
- 【招】阿里云技术战略高级专家
- 【优化充电】基于matlab蒙特卡洛算法求解电动汽车充电优化问题【含Matlab源码 1164期】
- 【DCVRP】基于matlab遗传和粒子群算法求解带容量的车辆路径规划问题【含Matlab源码 1034期】
- 【图像去噪】基于matlab GUI均值+中值+空间+高斯滤波图像去噪【含Matlab源码 763期】
- 【图像分割】基于matlab GUI FCMKFCM MRI图像分割【含Matlab源码 582期】