1

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 refs/data/val in the git fetch command?

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

Nemo
  • 24,540
  • 12
  • 45
  • 61
  • No, it is not a duplicate. – Nemo Nov 17 '16 at 03:14
  • Possible duplicate of: http://stackoverflow.com/questions/292357/what-are-the-differences-between-git-pull-and-git-fetch – Tim Biegeleisen Nov 17 '16 at 03:16
  • 1
    Possible duplicate of [How do I fetch only one branch of a remote git repository?](http://stackoverflow.com/questions/6368987/how-do-i-fetch-only-one-branch-of-a-remote-git-repository) – Joe Nov 17 '16 at 03:33

2 Answers2

2

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.

torek
  • 448,244
  • 59
  • 642
  • 775
1

This might provide some insight for the overall workflow:
What is the difference between pull and clone in git?

As for the second question, he was fetching the branch refs/data/val from the repo at his *.git link.

Community
  • 1
  • 1
Eric M.
  • 642
  • 5
  • 16