Skip to content

Wrong commit order #779

Open
Open
@ffleandro

Description

@ffleandro

I'm seeing some cases where the git history shows commits in the wrong order from which they were created.

Here is my code:

    await this.git.checkout('master');
    await this.git.add('.');
    await this.git.commit('commit 1');
    const hash = await this.git.revparse('HEAD');
    
    await this.git.checkout(['-b', 'new_branch']);
    // apply some changes in a file
    await this.git.add('.');
    await this.git.commit('commit 2');
    await this.git.addTag('new_tag');
    await this.git.push(['--atomic', 'origin', 'master', 'new_branch', 'new_tag']);
    await this.git.checkout('master');

What I expected was to always branch new_branch from the commit 1, but sometimes the branch is made before the commit 1.

Result:

4282224 (HEAD -> master) commit 1
1752c05 (tag: new_tag, new_branch) commit 2
5db3065 Base commit

It seems that commit 4282224 and 1752c05 are in the wrong order.

I'm I doing something wrong or is this the expected behaviour?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions