我能做点什么吗
git add -A
git commit -m "commit message"
一个命令?
我似乎经常使用这两个命令,如果Git有一个像Git commit -Am“commit message”这样的选项,它会让生活变得更方便。
git commit有-a修饰符,但它不完全等同于在提交前执行git add -a。git add -A添加新创建的文件,但git commit -am不添加。什么?
我能做点什么吗
git add -A
git commit -m "commit message"
一个命令?
我似乎经常使用这两个命令,如果Git有一个像Git commit -Am“commit message”这样的选项,它会让生活变得更方便。
git commit有-a修饰符,但它不完全等同于在提交前执行git add -a。git add -A添加新创建的文件,但git commit -am不添加。什么?
当前回答
对于人群中的银背,他们习惯了Subversion……我通常在我的项目的根目录中添加如下内容(在windows中作为一个bat文件,例如git-commit.bat)。然后当我想添加、提交和推送时,我只需输入git-commit“添加了一些新东西”这样的东西,它就会全部到远程回购。
此外,这样项目中的任何人都可以使用相同的,而不必在本地更改任何内容。
我通常也运行git配置凭证。helper存储一次,所以我不需要给uid/pwd时,这是运行。
::
:: add, commit, and push to git
::
@echo off
echo.
echo.
echo
echo Doing commit...
git add -A && git commit -m %1
echo.
echo.
echo Doing push...
git push
echo.
echo.
echo Done.
echo.
其他回答
最简单的方法是:
git commit -am "Your commit message"
我不明白我们为什么要搞得这么复杂。
如果你输入:
git config --global alias.a '!git add -A && git commit -m'
一次,你只需要打字
git a
每一次:
git a 'your comment'
git commit -am "message"
是告诉git删除已删除文件的一种简单方法,但我通常不推荐这种一刀切的工作流程。在最佳实践中,Git提交应该是相当原子的,并且只影响少数文件。
git add .
git commit -m "message"
是添加所有新建或修改过的文件的简单方法。此外,适用于所有限定条件。上述命令不会删除未使用git rm命令删除的文件。
git add app
git commit -m "message"
是一种将所有文件从单个目录添加到索引的简单方法,在本例中是app目录。
我使用以下方法(这两种方法都在进行中,所以我会尽量记得更新):
# Add All and Commit
aac = !echo "Enter commit message:" && read MSG && echo "" && echo "Status before chagnes:" && echo "======================" && git status && echo "" && echo "Adding all..." && echo "=============" && git add . && echo "" && echo "Committing..." && echo "=============" && git commit -m \"$MSG\" && echo "" && echo "New status:" && echo "===========" && git status
# Add All and Commit with bumpted Version number
aacv = !echo "Status before chagnes:" && echo "======================" && git status && echo "" && echo "Adding all..." && echo "=============" && git add . && echo "" && echo "Committing..." && echo "=============" && git commit -m \"Bumped to version $(head -n 1 VERSION)\" && echo "" && echo "New status:" && echo "===========" && git status
呼应“Enter commit message:”&&读取MSG部分,灵感来自Sojan V Jose
我想在那里得到一个if else语句,这样我就可以让aacv问我,如果我想部署时,如果我键入'y',为我这样做,但我想我应该把它放在我的.zshrc文件
您可以使用git别名,例如:
git config --global alias.add-commit '!git add -A && git commit'
用在
git add-commit -m 'My commit message'
EDIT:返回到ticks('),否则在Linux上shell扩展将失败。在Windows上,应该使用双引号(")来代替(在评论中指出,没有验证)。