好的,所以我遇到了一个问题,或者可能没有,我只是不明白。
我正在做的是尝试提交并推送提交,但也标记它。
我是通过gulp运行shell命令来做到的,但这可能与它有关,
git add [files]
git commit -m [message]
git tag -a [tag name] [branch] -m [message]
然后
git push origin [tag name]
但问题是标签是在先前的提交上推送的,而不是我目前提交的内容。
我目前的gulp任务如下:
var gulp = require('gulp'),
plugin = require('gulp-load-plugins')({
camelize: true
}),
ghPages = require('gulp-gh-pages'),
run = require('gulp-run'),
prompt = require('gulp-prompt');
module.exports = function() {
console.log('Deployment is running currently, please be patient.');
return gulp.src('modules/**/*')
.pipe(ghPages({
remoteUrl: '[user]@[ip]:[branch]',
branch: '[branch]'
}))
.on('end', function() {
return gulp.src('modules/**/*')
.pipe(prompt.prompt({
type: 'input',
name: 'release',
message: 'Is this a new release? (y/n)',
}, function( res ) {
if ( res.release == 'y' ) {
return gulp.src('modules/**/*', {
read: false
})
.pipe(prompt.prompt({
type: 'input',
name: 'releaseNumber',
message: 'What is the new release version number? (e.g. x.x.x)'
}, function( res ) {
run('git fetch --all').exec();
run('git tag -a v' + res.releaseNumber + ' [branch] -m "Bump release"').exec();
run('git push origin v' + res.releaseNumber + ' [branch]').exec();
}));
}
}));
});
};
控制台的输出是:
Deployment is running currently, please be patient.
[16:12:28] [gh-pages (branch)] Cloning repo
[16:12:28] [gh-pages (branch)] Checkout remote branch `branch`
[16:12:28] [gh-pages (branch)] Updating repository
[16:12:29] [gh-pages (branch)] Copying files to repository
[16:12:29] [gh-pages (branch)] Adding 1 files.
[16:12:29] [gh-pages (branch)] Committing "Update 2016-11-09T21:12:18.579Z"
[16:12:29] [gh-pages (branch)] Pushing to remote.
[16:12:30] Finished 'deploy' after 12 s
[16:12:30] Finished 'build' after 15 s
? Is this a new release? (y/n) y
? What is the new release version number? (e.g. x.x.x) 0.0.5
$ git tag -a v0.0.5 branch -m "Bump release"
$ git push origin v0.0.5
To [user]@[ip]:[repo]
* [new tag] v0.0.5 -> v0.0.5
正如您从图像中看到的那样,标记未被置于我目前提交的最新提交中。它将它添加到上一次提交。
我也在master
推动另一个[分支]。也许这可能是问题?
答案 0 :(得分:2)
您应该展示问题的实际示例。这是一个演示,它按预期工作:
#!/bin/bash
init() {
git init --bare demo.git
git clone --quiet demo.git demo
}
commit_line () {
echo $1 > file
git add file
git commit -m "$2"
}
init
pushd demo
commit_line one first
commit_line two second
git tag -a -m "tag msg" tag-name HEAD
git push origin master tag-name
运行该脚本以创建demo.git
裸存储库和demo
工作文件夹。运行之后,我运行以下命令:
pat@here ~/tmp/demo.git $ git log --graph --decorate --abbrev-commit --oneline
* 06a067a (HEAD -> master, tag: tag-name) second
* daa72b4 first
因此标记已与最近的提交正确关联,该提交也是master
的提示,当前也是HEAD
。在工作文件夹中它看起来很相似,除了我们还看到本地主机与上游存储库匹配。
pat@here ~/tmp/demo $ git graph
* 06a067a (HEAD -> master, tag: tag-name, origin/master) second
* daa72b4 first
答案 1 :(得分:2)
我已经关注了你的gulpfile中的命令,并在我的机器上运行以下命令
$ git clone https://github.com/jkulak/git-test
$ cd git-test/
$ touch first-file
$ git add first-file
$ git commit -m "Create first commit"
$ touch second-file
$ git add second-file
$ git commit -m "Create second commit"
$ git tag -a tag1 master -m "Creating first tag after second commit"
$ git push origin master
$ git push origin tag1
当我查看GitHub时,我看到了:
7008d2d
7008d2d
两者都指向/具有相同的散列/提交。
所以你写的"标签被推送到先前的提交而不是我目前提交的内容。"似乎不是事实 - 可以请仔细检查一下吗?
我也不明白你的最后一句话 - 你介意澄清一下吗?
也是在推后,只是为了确定
$ git log
* 7008d2d (HEAD -> master, tag: tag1, origin/master) Create second commit
* b6d13c4 Creted first commit
它在当地看起来也不错。