git commit -m与git commit -am [英] git commit -m vs. git commit -am

查看:85
本文介绍了git commit -m与git commit -am的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

似乎很简单,但我不明白.我是我应用程序的根源.

Seems easy but I just don't get it. I am in the root of my application.

这是我的工作流程.

git add .
git commit -m "added a new feature some files changed"
git push heroku master

这通常有效.我所有的更改都已推送.

This usually works. All my changes are pushed.

但是有时候我有一个要更改的文件,但是当我将其推送到Heroku时,那个文件没有更改...但是对于大多数文件,更改都存在...

But sometimes I have a file that I change but when I push to Heroku the changes are not there for THAT ONE FILE... but for most of the files the changes are there...

但如果我这样做

git add .
git commit -am "added a new feature some files changed"
git push heroku master

所有内容(所有更改)都推送到Heroku

Everything (all changes) are pushed to Heroku

推荐答案

来自

git commit -a 在提交之前自动暂存所有已跟踪的,已修改的文件 .如果您认为工作流程的git add阶段是 太麻烦了,Git允许您使用-a选项跳过该部分. 这基本上告诉Git在任何被跟踪"的文件上运行git add -也就是说,您上一次提交中的任何文件都已被修改.这样,您可以在以下情况下执行更多的Subversion样式工作流程 您想要的只是编辑文件,然后在您运行git commit -a时 想要快照所有已更改的内容.你还需要 不过,像Subversion一样,运行git add开始跟踪新文件.

git commit -a automatically stage all tracked, modified files before the commit If you think the git add stage of the workflow is too cumbersome, Git allows you to skip that part with the -a option. This basically tells Git to run git add on any file that is "tracked" - that is, any file that was in your last commit and has been modified. This allows you to do a more Subversion style workflow if you want, simply editing files and then running git commit -a when you want to snapshot everything that has been changed. You still need to run git add to start tracking new files, though, just like Subversion.

使用选项-am允许您在一个命令中添加并创建消息以提交.

Using the option -am allows you to add and create a message for the commit in one command.

这篇关于git commit -m与git commit -am的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆