Git: References

Git references located in .git/refs folder

.git/refs/heads is the position of commit based on branch (HEAD) in the local repository

.git/refs/remotes/<remote-name> is the position of commit based on branch (HEAD) in the remote repository

.git/refs/tags is the position of commit based on tag in the local repository

Push commit to new remote branch

git push <remote-name> <local-branch>:<new-remote-branch>
git push <remote-name> <local-commit>:<new-remote-branch>

Since this is a new remote branch, we do not have the refs in .git/refs/remotes/<remote-name> folder yet. To work around this, we tell git to push (and create) to the remote refs/heads/<new-remote-branch>.

git push <remote-name> <local-branch>:refs/heads/<new-remote-branch>
git push <remote-name> <local-commit>:refs/heads/<new-remote-branch>

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *