Nemo Nemo - 4 months ago 21
Git Question

Git development without clone

I am new to git and I am familiar with the regular git clone, develop, commit, push workflow. In one of the tutorials I watched, I noticed the developer doing the following:

git init
git fetch ssh://someserver.git refs/data/val
git checkout FETCH_HEAD
. make changes to files
git commit -am "somemessage"
git push ssh://someserver.git HEAD:refs/data/val

Could someone help to explain:

  1. What workflow is being followed here? What could be the reason of doing this without cloning?

  2. What is the meaning of
    in the
    git fetch

NOTE: This is not to understand what FETCH_HEAD is. So it is not a duplicate.


That's a weird workflow, and not really useful in general. Its main feature is using a peculiar reference namespace, treating refs/data/val as if it were a branch name.

The effect is like cloning with --single-branch, except that instead he clones with no branch, then treats the funny ref as if it were a branch.

The git checkout step produces a detached HEAD.

The subsequent commit makes a new commit that extends the detached HEAD.

The final git push updates the other Git, continuing to treat the peculiarly named reference as a branch. The other Git is free to reject the push. Many/most would do simply because refs/data/ is not a known-to-be-safe namespace for pushes.

Since there is no named remote, the remote's branch-names cannot be stored locally for convenience in merging and/or rebasing. Since there are no named branches, Git's built-in branch behavior cannot be used for convenience in committing, merging, and/or rebasing. Since there are neither named branches, nor a named remote, Git's built-in push behavior cannot be used, requiring the fully-spelled-out URL and HEAD-to-ref push.

In short, this is an inconvenient way to use Git unconventionally.