安装配置
$ git config --global user.name "Your Name"
$ git config --global user.email your.email@example.com
使用co作为checkout的alias
$ git config --global alias.co checkout
设置git的默认编辑器
$ git config --global core.editor "subl -w"
Replace "subl -w" with "mate -w" for TextMate, "gvim -f" for gVim, or "mvim -f" for MacVim.
初始化git空文件夹
$ git init
Initialized empty Git repository in /Users/mhartl/rails_projects/first_app/.git/
配置rails命令生成的.gitignore文件
# Ignore bundler config
/.bundle
# Ignore the default SQLite database.
/db/*.sqlite3
# Ignore all logfiles and tempfiles.
/log/*.log
/tmp
Mac OS 如此配置
# Ignore bundler config
/.bundle
# Ignore the default SQLite database.
/db/*.sqlite3
# Ignore all logfiles and tempfiles.
/log/*.log
/tmp
# Ignore other unneeded files.
doc/
*.swp
*~
.project
.DS_Store
add和commit
$ git add .
查看状态
$ git status
# On branch master
#
# Initial commit
#
# Changes to be committed:
# (use "git rm --cached <file>..." to unstage)
#
# new file: README.rdoc
# new file: Rakefile
...
提交命令
$ git commit -m "Initial commit"
[master (root-commit) df0a62f] Initial commit
42 files changed, 8461 insertions(+), 0 deletions(-)
create mode 100644 README.rdoc
create mode 100644 Rakefile
(-m让你添加一条提交信息)
查看git日志
$ git log
commit df0a62f3f091e53ffa799309b3e32c27b0b38eb4
Author: Michael Hartl <michael@michaelhartl.com>
Date: Thu Oct 15 11:36:21 2009 -0700
Initial commit
...
关于回滚
$ git checkout -f
$ git status
# On branch master
nothing to commit (working directory clean)
$ ls app/controllers/
application_controller.rb
(-f强制重写当前改变)
关于同步到远程github
$ git remote add origin git@github.com:<username>/first_app.git
$ git push origin master
关于git的分支
$ git checkout -b modify-README
Switched to a new branch 'modify-README'
$ git branch
master
* modify-README
(使用checkout的-b创建分支,git branch查看当前所有的分支,*说明当前的分支
git checkout -b modify-README创建分支并转换到当前分支
关于git的编辑功能
$ git mv README.rdoc README.md
$ subl README.md
mv类似unix的mv
新的README.md
# Ruby on Rails Tutorial: first application
This is the first application for
[*Ruby on Rails Tutorial: Learn Rails by Example*](http://railstutorial.org/)
by [Michael Hartl](http://michaelhartl.com/).
$ git status
# On branch modify-README
# Changes to be committed:
# (use "git reset HEAD <file>..." to unstage)
#
# renamed: README.rdoc -> README.md
#
# Changed but not updated:
# (use "git add <file>..." to update what will be committed)
# (use "git checkout -- <file>..." to discard changes in working directory)
#
# modified: README.md
#
提交
$ git commit -a -m "Improve the README file"
2 files changed, 5 insertions(+), 243 deletions(-)
delete mode 100644 README.rdoc
create mode 100644 README.md
(-a提交所有改变)
关于合并Merge
$ git checkout master
Switched to branch 'master'
$ git merge modify-README
Updating 34f06b7..2c92bef
Fast forward
README.rdoc | 243 --------------------------------------------------
README.md | 5 +
2 files changed, 5 insertions(+), 243 deletions(-)
delete mode 100644 README.rdoc
create mode 100644 README.md
合并了所有changes后可以执行以下命令
$ git branch -d modify-README
Deleted branch modify-README (was 2c92bef).
用以删除合并了的分支,这步可选
# For illustration only; don't do this unless you mess up a branch
$ git checkout -b topic-branch
$ <really screw up the branch>
$ git add .
$ git commit -a -m "Major screw up"
$ git checkout master
$ git branch -D topic-branch
使用git branch -D 遗弃分支
(与-d不同,-D可以删除没有合并过的分支)
关于push
$ git push
在大多数系统上可以省略origin master直接使用git push
在某些系统上会出现问题
$ git push
fatal: The current branch master is not tracking anything.
分享到:
相关推荐
git学习,git魔法,git 应用,git 入门。
GIt入门与应用
git是当下较为流行的分布式版本控制工具,了解并简单实用git已经成为程序开发者的必备技能。学习git轻松入门,以及常用的命令及应用场景介绍。
Git简介 Git是一个帮助开发者追踪代码变化和...5、安装完成后,你可以通过Terminal或其他终端应用程序访问Git。 Git配置环境变量 把git的bin 目录,路径完整加入系统变量,在cmd中输入git; 在cmd内输入 git --ver
git版本管理教程入门资料,建立本地分支、远程分支并建立两者之间的联系,实际应用举例
Git-play是一个自定义git命令,用于从远程git存储库非常轻松地部署应用程序服务器。 它每分钟检查一次远程git存储库,如果发生了什么变化,它将自动重新启动应用程序服务器。 安装 您可以使用pip或easy_install从...
自己整理的git学习笔记,能够很容易地学会应用git
亲,本文是Git使用入门教程,Git是一个版本控制系统,更是一个分布式文件管理系统,里面的道道,一大堆学起来之后你才感觉到它的强大。本文比较全面的介绍了它的基础操作及基本应用。
堆叠 Git Stacked Git,简称 StGit ,是一个将 Git 提交作为补丁堆栈进行管理的应用程序。 使用补丁堆栈工作流,可以同时高效地开发多个补丁,每个补丁专注于一个问题,从而实现干净的 Git 提交历史并提高生产力。 ...
入门 打开一个终端并执行以下步骤: 克隆项目 git clone git://github.com/matsev/git-build-number.git 变更目录 cd git-build-number 作为Web应用程序执行项目 mvn jetty:run-war 浏览到
node-js-入门 使用准系统 Node.js 应用程序。 此应用程序支持文章 - 请查看。 在本地运行 确保你已经安装了和 。 $ git clone git@github.com:heroku/node-js-getting-started.git # or clone your own fork $ cd ...
本文不是一篇Git入门教程,这样的文章一搜一大把,我是要从具体实践角度,尤其是在团队协作中,阐述如何去好好地应用Git。既然是讲在团队中的应用实践,我就尽可能地结合实际场景来讲述。如果一个团队在使用Git时...
git-hooked install pre-commit 挂钩列出的每个钩子都可用: applypatch-msg 预应用补丁后应用补丁预提交准备提交消息提交消息提交后预变基结帐后合并后预推预收更新收到后更新后一键结账预自动GC 重写后变基用户...
入门将其添加到您的项目中: > npm install dugite然后在您的应用程序中引用它: import { GitProcess , GitError , IGitResult } from 'dugite'const pathToRepository = 'C:/path/to/git/repository/'const result...
已归档团队的AngularJS应用入门对于团队来说,这是一个自以为是的AngularJS应用程序入门者,具体取决于和其他适用于一般JavaScript以及特定于AngularJS的最佳实践。要求始终最好让您的机器运行最新版本的机器: 吉特...
MetroGit是一个本地桌面git应用程序,将JIRA,AppVeyor和其他工具集成到一个一致的UI中。 因此,不再需要切换窗口并在浏览器选项卡之间跳转 :nerd_face: 。 更多集成和功能仍未到来... 功能亮点 带有提交细节的地铁...
Gitpod提醒要在Gitpod中运行前端(仅HTML,CSS,Javascript)应用程序,请在终端中输入: python3 -m http.server 应该会出现一个蓝色按钮,以单击: “公开” , 应该出现另一个蓝色按钮,以单击:打开浏览器。...
但是,如果您确实想要运行您的应用程序,您需要将代码放在远程系统上,这会带来一个问题。 特别是如果您的本地机器和远程机器之间没有惊人的快速连接。 此工具将本地文件系统和远程系统“带外”同步,因此中断更少...
loggit可以像您想要的那样简单和不loggit也可以根据您的应用程序的需要而涉及。 请参见下面的一些快速示例,并入门指南》以及其他一些用例示例。为什么要使用loggit ? 确实有一些可用于R. loggit日志记录软件包,...