上次提交时的Git标记

上次提交时的Git标记,git,Git,好吧,我遇到了一个问题,也许不是,我只是不明白 我正在做的是尝试提交和推送提交,但也标记它 我是通过gulp运行shell命令来实现这一点的,所以这可能与此有关 git添加[文件] git提交-m[消息] git标记-a[标记名][分支]-m[消息] 然后 git推送原点[标记名] 但问题是标签是在前一次提交时推送的,而不是我当前提交的 我当前的吞咽任务如下所示: var gulp = require('gulp'), plugin = require('gulp-load-plugins')(

好吧,我遇到了一个问题,也许不是,我只是不明白

我正在做的是尝试提交和推送提交,但也标记它

我是通过gulp运行shell命令来实现这一点的,所以这可能与此有关

git添加[文件]

git提交-m[消息]

git标记-a[标记名][分支]-m[消息]

然后

git推送原点[标记名]

但问题是标签是在前一次提交时推送的,而不是我当前提交的

我当前的吞咽任务如下所示:

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
推到另一个[分支]。也许这就是问题所在

您应该展示一个问题的工作示例。下面是一个演示,它可以按预期工作:

#!/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
bare存储库和一个
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

您应该展示一个问题的工作示例。下面是一个演示,它可以按预期工作:

#!/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
bare存储库和一个
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

我已按照您的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
  • -tag1指向
    7008d2d
  • 两者都指向/具有相同的哈希/提交

    所以你写的“标签是在之前的提交中推送的,而不是我当前提交的。”似乎不是事实——请再检查一遍好吗

    我也不明白你的最后一句话-你介意澄清一下吗

    也是在推了之后,只是为了确定

    $ git log
    * 7008d2d (HEAD -> master, tag: tag1, origin/master) Create second commit
    * b6d13c4 Creted first commit
    

    本地看起来也不错。

    我已经按照您的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
  • -tag1指向
    7008d2d
  • 两者都指向/具有相同的哈希/提交

    所以你写的“标签是在之前的提交中推送的,而不是我当前提交的。”似乎不是事实——请再检查一遍好吗

    我也不明白你的最后一句话-你介意澄清一下吗

    也是在推了之后,只是为了确定

    $ git log
    * 7008d2d (HEAD -> master, tag: tag1, origin/master) Create second commit
    * b6d13c4 Creted first commit
    

    局部看起来也不错。

    更新了原始问题。抱歉没有包括所有内容。更新了原始问题。抱歉,没有包括所有内容。更新了带插图的问题,还删除了最后一句,因为它让人困惑lol。sorry更新了带插图的问题,还删除了最后一句,因为它让人困惑lol。抱歉
    git标记
    不会创建提交。对。它创建标记。提交已在此行创建并推送
    [16:12:29][gh pages(branch)]添加1个文件。[16:12:29][gh pages(branch)]提交“更新2016-11-09T21:12:18.579Z”[16:12:29][gh pages(branch)]推送至远程。
    所以您推送至
    词典模块
    ?这不会创建一个快进合并提交,从而创建新的哈希吗?尝试在不使用gulpfile的情况下使用git命令复制它。我只是根据您的答案尝试使用git命令,它不会推送到我不在的分支。它推送标记,但不推送提交。我在master上做更改,然后我需要将它们推送到另一个分支,而不签出该分支。
    git标记
    不会创建提交。对。它创建标记。提交已在此行创建并推送
    [16:12:29][gh pages(branch)]添加1个文件。[16:12:29][gh pages(branch)]提交“更新2016-11-09T21:12:18.579Z”[16:12:29][gh pages(branch)]推送至远程。
    所以您推送至
    词典模块
    ?这不会创建一个快进合并提交,从而创建新的哈希吗?尝试在不使用gulpfile的情况下使用git命令复制它。我只是根据您的答案尝试使用git命令,它不会推送到我不在的分支。它推送标记,但不推送提交。我在master上做更改,然后我需要将它们推送到另一个分支,而不签出该分支。