unable to delete git branch due to "renamed branch" - github

I've scoured several different posts but there doesn't appear to be any that match with this exact issue of an "apparent" branch renaming occurring but nothing seeming to line up.
Essentially, I've been trying to delete a remote branch off of an enterprise git version but I've been getting rejected and I was wondering if there was any additional steps I can try out?
here is the following CLI information:
| => git branch -a
* master
remotes/origin/HEAD -> origin/master
remotes/origin/master
remotes/origin/releases/v1.7.2_log4j2
(base)
| ~/Documents/<repo> # (user)
| => git push origin -d releases/v1.7.2_log4j2
To https://github.<company>.com/<org>/<repo>.git
! [remote rejected] releases/v1.7.2_log4j2 (branch releases/v1.7.2_log4j2 is being renamed)
error: failed to push some refs to 'https://github.<company>.com/<org>/<repo>.git'
My git version: 2.24.3 (Apple Git-128).
EDIT: there are no branch protection rules that apply to this branch and I have tried the command in the suggestions of git push -d origin releases<1.7.2_log4j2 with the same result

This looks like a github issue. There is a github-community thread where someone got the exact same message and it turned out to be a flag that was set within the github system that marked the branch as being renamed at the moment. They had to ask the github-support to clear that flag and then were able to delete the branch.

You seem to have your parameters backwards. Try
git push -d origin releases/v1.7.2_log4j2

Related

'git branch' does not show the branches names

I am using git on ubuntu.
git branch does not show the branches' names. I tried cloning different repositories, but again git branch does not show the branches' names.
I have also created a new repository and it is the same.
Example:
>git clone https://github.com/uber/pyro.git
Cloning into 'pyro'...
remote: Counting objects: 13342, done.
remote: Compressing objects: 100% (23/23), done.
remote: Total 13342 (delta 8), reused 0 (delta 0), pack-reused 13319
Receiving objects: 100% (13342/13342), 55.85 MiB | 5.34 MiB/s, done.
Resolving deltas: 100% (9814/9814), done.
>ls
pyro
>cd pyro
>git branch -a
>git branch -r
>git branch
>git status
On branch dev
Your branch is up to date with 'origin/dev'.
Adding another branch:
>git checkout -b branch1
Switched to a new branch 'branch1'
>git branch
>
I have also committed one time. and it is the same.
>GIT_TRACE=1 git branch
15:39:13.295464 git.c:344 trace: built-in: git branch
15:39:13.296121 run-command.c:640 trace: run_command: unset
GIT_PAGER_IN_USE; LESS=FRX LV=-c pager
>git --version
git version 2.17.1
>
>env -i git branch
WARNING: terminal is not fully functional
* devress RETURN)
>
I have tested the same commands on another laptop and it works. (I have also uninstalled git and reinstalled it. It doesn't help)
Any idea how to fix it?
This is not a complete answer, but based on a lengthy chat discussion, it looks like some kind of interaction with the pager.
The user's environment includes these variables (among others):
LESSOPEN='| /usr/bin/lesspipe %s'
LESSCLOSE='/usr/bin/lesspipe %s %s'
Those are the default settings on Ubuntu, so that shouldn't be causing a problem.
git branch produces no output.
GIT_PAGER=/bin/cat git branch produces the correct output.
I haven't yet figured out why the pager should be causing this problem, but since changing GIT_PAGER to /bin/cat is a workaround, that must be what the issue is.
Show local branches:
git branch
Since you are cloning from remote/origin branches, it will not displaying using git branch. you need to at least visit that branch by using git checkout. Review below git commands. I have created new branch hotfix-test and then used git branch
~/pyro (dev)
$ git checkout -b hotfix-test
Switched to a new branch 'hotfix-test'
~/pyro (hotfix-test)
$ git branch
dev
* hotfix-test
Checkout the current branch to existing other branch.
$ git checkout lax
Switched to a new branch 'lax'
Branch lax set up to track remote branch lax from origin.
~/pyro (lax)
$ git branch
dev
hotfix-test
* lax
Cloning steps and origin branches
~/desktop (master)
$ git clone https://github.com/uber/pyro.git
Cloning into 'pyro'...
remote: Counting objects: 13342, done.
remote: Compressing objects: 100% (23/23), done.
remote: Total 13342 (delta 8), reused 0 (delta 0), pack-reused 13319
Receiving objects: 100% (13342/13342), 55.85 MiB | 2.69 MiB/s, done.
Resolving deltas: 100% (9814/9814), done.
~/desktop (master)
$ cd pyro
desktop/pyro (dev)
$ git branch -a
* dev
remotes/origin/0.1.2-release
remotes/origin/0.2.0-release
remotes/origin/0.2.1-release
remotes/origin/HEAD -> origin/dev
remotes/origin/ast-char-rnn
remotes/origin/bnn-mnist
remotes/origin/causal-tutorial
remotes/origin/continuation-poutine
remotes/origin/continuation-with-indep
remotes/origin/cubo
remotes/origin/dev
remotes/origin/dice-elbo
remotes/origin/gh-pages
remotes/origin/glom-autoname
remotes/origin/hmc
remotes/origin/jit-integration-tests
remotes/origin/lax
remotes/origin/lax2
remotes/origin/maps-iei
remotes/origin/master
remotes/origin/mvn-sym
remotes/origin/mvncv
remotes/origin/nightmare-poutine
remotes/origin/nips-2017
remotes/origin/only-continuation-poutine
remotes/origin/only-parallel-enumeration
remotes/origin/paul-mh-12-1
remotes/origin/pcg
remotes/origin/pragmatics-example
remotes/origin/ps-semaphore
remotes/origin/pyro_GP
remotes/origin/recursion-scope
remotes/origin/regtest-1
remotes/origin/rejector-research
remotes/origin/revert-611-verlet-pr
remotes/origin/rsa-ccg-example
remotes/origin/sampling-hash
remotes/origin/snorkel-example
remotes/origin/trace-posterior-sample-fix
remotes/origin/tst
remotes/origin/vec-rand-module
~/desktop/pyro (dev)
$ git branch -r
origin/0.1.2-release
origin/0.2.0-release
origin/0.2.1-release
origin/HEAD -> origin/dev
origin/ast-char-rnn
origin/bnn-mnist
origin/causal-tutorial
origin/continuation-poutine
origin/continuation-with-indep
origin/cubo
origin/dev
origin/dice-elbo
origin/gh-pages
origin/glom-autoname
origin/hmc
origin/jit-integration-tests
origin/lax
origin/lax2
origin/maps-iei
origin/master
origin/mvn-sym
origin/mvncv
origin/nightmare-poutine
origin/nips-2017
origin/only-continuation-poutine
origin/only-parallel-enumeration
origin/paul-mh-12-1
origin/pcg
origin/pragmatics-example
origin/ps-semaphore
origin/pyro_GP
origin/recursion-scope
origin/regtest-1
origin/rejector-research
origin/revert-611-verlet-pr
origin/rsa-ccg-example
origin/sampling-hash
origin/snorkel-example
origin/trace-posterior-sample-fix
origin/tst
origin/vec-rand-module
See Also
Why is "git branch" silent in new repositories?
I have disabled the git pager for the git branch by using git config --global pager.branch false. Now I can get the git branch output. But we didn't figure out what is the pager problem. For the other commands like git diff, the same problem exists.

Customize comment in Jira - GitHub integration

Is it possible to customize what is commented in Jira when a commit is pushed in GitHub?
Currently the following information is commented:
Triggered by: John Doe
Comment: #TST-1234: dummy commit to test jira-github integration
Repository: testing
Branch: refs/heads/master
Git Issue URL: https://github.com/...
And I want it to comment only the URL part, all the rest is not interesting information for me, and I want the comments to be clean.
a possible solution could be to customize the commit message itself
ensure that commit messages include the branch name, which in JIRA are most likely derived from the issue title.
To achieve this, coworkers have to include in their .git/hooks directory a file named commit-msg with the following contents :
#!/bin/bash
current_branch="$(git rev-parse --abbrev-ref HEAD)"
tmp=$(mktemp) || exit
echo "$current_branch $(cat "$1")" > "$tmp"
mv "$tmp" "$1"
Then when someone is committing on the feature branch ABC-1234-customers-cant-log-in, a commit command like this :
git commit -m "Awesome changes"
...will actually produce the following commit message :
ABC-1234-customers-cant-log-in Awesome changes
...and JIRA will then link the commit to the issue.
solution and credits goes to answer here: https://stackoverflow.com/a/55008618/7540322

svn2git error PROPFIND request failed

I have Ruby, RubyGems, and svn2git installed under 32 bit windows 7.
svn2git https://code.google.com/p/skyrim-plugin-decoding-project/ --rootistrunk --revision 1:1693 --authors ~/authors.txt --verbose
The above line returns the following error:
Running command: git svn init --prefix=svn/ --no-metadata --trunk=https://code.g
oogle.com/p/skyrim-plugin-decoding-project/
Initialized empty Git repository in e:/tes5edit/.git/
RA layer request failed: PROPFIND request failed on '/p/skyrim-plugin-decoding-p
roject': PROPFIND of '/p/skyrim-plugin-decoding-project': 405 Method Not Allowed
(https://code.google.com) at /usr/lib/perl5/site_perl/Git/SVN.pm line 310
command failed:
git svn init --prefix=svn/ --no-metadata --trunk=https://code.google.com/p/skyri
m-plugin-decoding-project/
I read something about svnadmin so I tried the following
svnadmin: E205000: Repository argument required
I don't know what the argument would be.
I have never used GitBash or any of these programs. I have no idea what the proper commands would be to resolve the issue. I am also new to Git and have very little experience with it.
git svn clone http://my-project.googlecode.com/svn/ \
--authors-file=users.txt --no-metadata -s my_project
The standard commands also give errors
E:\TES5Edit_Git> git svn init https://code.google.com/p/skyrim-plugin-decoding-p
roject/
Initialized empty Git repository in E:/TES5Edit_Git/.git/
E:\TES5Edit_Git [master]> git config svn.authorsfile ./authors.txt
E:\TES5Edit_Git [master +1 ~0 -0 !]> git svn fetch
RA layer request failed: PROPFIND request failed on '/p/skyrim-plugin-decoding-p
roject': PROPFIND of '/p/skyrim-plugin-decoding-project': 405 Method Not Allowed
(https://code.google.com) at /usr/lib/perl5/site_perl/Git/SVN.pm line 148
E:\TES5Edit_Git [master +1 ~0 -0 !]>
As long as it makes a repo I can push I don't care how I do it. However, I did not start with a standard setup in the beginning and no idea what I was doing. So I want the clone to start at commit 1 and consider root as master, and all commits that make any kind of folder, rename folders, move folders, delete folders, all of everything created as branches.
After asking some friends I realized I had been using the wrong URL.
svn2git http://skyrim-plugin-decoding-project.googlecode.com/svn/ --rootistrunk --revision 1:1693 --authors ~/authors.txt --verbose
That would have been the correct init statment

Referencing current branch in github readme.md

In my github repo's readme.md file I have a Travis-CI badge. I use the following link:
https://travis-ci.org/joegattnet/joegattnet_v3.png?branch=staging
The obvious problem is that the branch is hardcoded. Is it possible to use some sort of variable so that the branch is the one currently being viewed?
Not that I know of.
GitHub support confirms (through OP Joe Gatt 's comment)
The only way to do this would be to pass the link through my own service which would use the github's http referrer header to determine which branch is being referenced and then fetch the appropriate image from Travis CI
I would rather make one Travis-CI badge per branch, for the reader to choose or consider the appropriate when seeing the README.md.
Update 2016 (3 years later): while nothing has changed on the GitHub side, fedorqui reports in the workaround mentioned in "Get Travis Shield on Github to Reflect Selected Branch Status" by Andrie.
Simply display all the branches and their respective TravisCI badges.
If you have only two or three branches, that could be enough.
I worked around this issue with a git pre-commit hook that re-writes the Travis line in the README.md with the current branch. An example of usage and pre-commit (Python) code (for the question as asked) are below.
Usage
dandye$ git checkout -b feature123 origin/master
Branch feature123 set up to track remote branch master from origin.
Switched to a new branch 'feature123'
dandye$ echo "* Feature123" >> README.md
dandye$ git add README.md
dandye$ git commit -m "Added Feature123"
Starting pre-commit hook...
Replacing:
[![Build Status](https://travis-ci.org/joegattnet/joegattnet_v3.png?branch=master)][travis]
with:
[![Build Status](https://travis-ci.org/joegattnet/joegattnet_v3.png?branch=feature123)][travis]
pre-commit hook complete.
[feature123 54897ee] Added Feature123
1 file changed, 2 insertions(+), 1 deletion(-)
dandye$ cat README.md |grep "Build Status"
[![Build Status](https://travis-ci.org/joegattnet/joegattnet_v3.png?branch=feature123)][travis]
dandye$
Python code for the pre-commit code
dandye$ cat .git/hooks/pre-commit
#!/usr/bin/python
"""
Referencing current branch in github readme.md[1]
This pre-commit hook[2] updates the README.md file's
Travis badge with the current branch. Gist at[4].
[1] http://stackoverflow.com/questions/18673694/referencing-current-branch-in-github-readme-md
[2] http://www.git-scm.com/book/en/v2/Customizing-Git-Git-Hooks
[3] https://docs.travis-ci.com/user/status-images/
[4] https://gist.github.com/dandye/dfe0870a6a1151c89ed9
"""
import subprocess
# Hard-Coded for your repo (ToDo: get from remote?)
GITHUB_USER="joegattnet"
REPO="joegattnet_v3"
print "Starting pre-commit hook..."
BRANCH=subprocess.check_output(["git",
"rev-parse",
"--abbrev-ref",
"HEAD"]).strip()
# String with hard-coded values
# See Embedding Status Images[3] for alternate formats (private repos, svg, etc)
# [![Build Status](https://travis-ci.org/
# joegattnet/joegattnet_v3.png?
# branch=staging)][travis]
# Output String with Variable substitution
travis="[![Build Status](https://travis-ci.org/" \
"{GITHUB_USER}/{REPO}.png?" \
"branch={BRANCH})][travis]\n".format(BRANCH=BRANCH,
GITHUB_USER=GITHUB_USER,
REPO=REPO)
sentinel_str="[![Build Status]"
readmelines=open("README.md").readlines()
with open("README.md", "w") as fh:
for aline in readmelines:
if sentinel_str in aline and travis != aline:
print "Replacing:\n\t{aline}\nwith:\n\t{travis}".format(
aline=aline,
travis=travis)
fh.write(travis)
else:
fh.write(aline)
subprocess.check_output(["git", "add", "README.md" ])
print "pre-commit hook complete."
I updated the work of Dan Dye so it's now able to change any git variable into a readme. It also works now with python 3. For example, handling badges by branch for Github actions:
[![Integration Tests](https://github.com/{{ repository.name }}/actions/workflows/integration-tests.yaml/badge.svg?branch={{ current.branch }})](https://github.com/{{ repository.name }}/actions/workflows/integration-tests.yaml?query=branch%3A{{ current.branch }})
And in your pre-commit file add:
.githooks/replace_by_git_vars.py readme.md README.md -v
-v displays the available variables and more
https://gist.github.com/jclaveau/af2271b9fdf05f7f1983f492af5592f8
Thanks a lot for the solution and inspiration!
The best solution for me was to create a server where I send a query with username and repo's name and get a svg image with the build status for all branches.

git svn interrupted, then i lost all the tags, how to fix it?

i am about to clone code from svn repo (on centos) using git svn clone -s svn://xxx, then it is interrupted for strange problems, the error message is as follows:
Following parent with do_switch
Successfully followed parent
Use of uninitialized value in concatenation (.) or string at /usr/lib/perl5/vendor_perl/5.8.8/i386-linux-thread-multi/SVN/Core.pm line 584.
Network connection closed unexpectedly: at /usr/libexec/git-core/git-svn line 2693
then i continue this clone process using
time git svn fetch -r HEAD
all the things seems goes well, and succeed to clone that svn repo at last:
W: -empty_dir: trunk/src/os/win32/ngx_gui.c
W: -empty_dir: trunk/src/os/win32/ngx_gui.h
W: -empty_dir: trunk/src/os/win32/ngx_gui_resources.h
W: -empty_dir: trunk/src/os/win32/ngx_shared.h
W: -empty_dir: trunk/src/os/win32/ngx_types.h
r4817 = 7b58fc00b5b8ebb0544053ecf63e53b28935f15b (refs/remotes/trunk)
Auto packing the repository for optimum performance. You may also
run "git gc" manually. See "git help gc" for more information.
Counting objects: 12449, done.
Compressing objects: 100% (12177/12177), done.
Writing objects: 100% (12449/12449), done.
Total 12449 (delta 9475), reused 0 (delta 0)
Checked out HEAD:
svn://svn.nginx.org/nginx/trunk r4817
real 0m9.630s
user 0m6.015s
sys 0m1.870s
the strange issue is that there is no tags in my local git repo which is cloned from svn repo:
[root#home nginx]# git branch
* master
[root#home nginx]# git tag // no tags at all:(
[root#home nginx]# svn ls svn://svn.nginx.org/nginx/branches | wc -l
7
[root#home nginx]# svn ls svn://svn.nginx.org/nginx/tags | wc -l
388
in fact there are 388 tags in the svn repo, so how to fix my local .git repo?
should i have to restart to git clone from the remote svn server?
i have tried many times, with the same problem:(
Basically git-svn doesn't support tags as Git tags. In order to convert SVN tags to Git tags you may use:
SubGit (+maybe svnsync if you have no access to the server with SVN repository)
git-svn + command for references update:
"git update-ref refs/tags/TAGNAME refs/remotes/tags/TAGNAME"
SmartGit, if you want some UI and not writing a script
But note: only the 1st and the 3rd solutions allow you to push tags to the server to be conerted to SVN tags. With git-svn you should use additional "git svn branch" command.