Search code examples
gitbitbucketbitbucket-apigitkraken

git push tag only and commit difference


I have small problem. Recently started using gitKraken to test how it works (thinking of moving from sourcetree). From what I understood it is more like "raw" git command. SourceTree does things for me like auto tag pushing (ok, found that it allows for not recommended --tags option)

My problem are tags. I tested it on console and it seems to be related to pushing tags.

git push origin - pushes changes
git push origin 1.0.0 - pushes tag
Here, everything is OK. My coworkers see changes and can pull it.

git push origin 1.0.0 - I push tag only, without commit (How is this possible?)
It is visible on Repository (on BitBucket site) like a normal commit - with comment and ID. However commit cannot be downloaded from bitbutcket via git pull since it states it is up-to-date

I have a feeling that it looks like
git push origin = git push origin
git push origin 1.0.0 = git push some-special-place

How exactly does it work? I can see all changes on BitBucket site.

Moreover I can download commited tag without commiting chnages and result I get is latest normally commited. Which can lead to problems in case I use API/Site to download repo copy, as it is not aligned with real changes

EDIT If My local commits are A-B-C-D(tag) and remote are A-B-C then BitBucket Interface shows me (after commiting a tag only) A-B-C-D and does not state that HEAD is on C Instead of D. That's what I thought I downlaod latest commit, but in reality What I was downloading was HEAD
Also, to note: Removing tag from remote removie
uncommited commits - like they were never there in first place.

GitKraken nor source tree does not inform about changes not being commited.

Edit: Commiting only tag shows real changes (patch summary) in web interface. Commit looks exactly as real one.


Solution

  • I think you are confusing the concepts of commits, branches and tags here.

    A tag is just a pointer to a commit. You can never refer to a tag (push it, check it out or whatever) without having pushed the commit it points to. git push origin <tag> will push the commit as well as the tag pointing to it.

    It will, however, not change any branch. A pull now is a combination of git fetch and git merge. If you pull from somewhere else, the pushed commit will be fetched. But merge merges the tracked remote branch into your local branch. The remote branch, however, did not change (since you only pushed the commit and tag, but did not change the branches HEAD). Thus, the up-to-date message shows when you pull.

    You can, however, checkout the commit on the other machine, since it has already been fetched. You cannot do that via the tag, however, unless you did a git pull --tags.

    Baseline:

    • git push origin <tag> does push the commit and the tag, but does not change the tracked branches' HEAD.
    • git push origin <branch> pushes new commits and updates the remote branches' HEAD, but does not push tags
    • git push origin (without tag or branch) will push the current branch by default. See git push documentation (by courtesy of @Melebius)

    Moreover I can download commited tag without commiting chnages and result I get is latest normally commited. Which can lead to problems in case I use API/Site to download repo copy, as it is not aligned with real changes

    I do not understand this part of your question, maybe you can elaborate on that. What do you mean by normally commited?