It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

User accidentally killed a branch in Git. Is there a way to get it back?

Zakir Sikder Apr 18, 2016

User accidentally killed a branch in Git.  Is there a way to get it back?

Please advise.

6 answers

1 accepted

1 vote
Answer accepted
Rahul Mohan Apr 18, 2016

the easiest way would be to see if anyone else has a local copy of that branch in their local and you can ask them to push that copy into remote repo.

0 votes
Rahul Mohan Apr 18, 2016

the other option is to check if you have a back up team who does back of the stash system every day and ask them to retrieve the only the info of that branch from the repo id in STASH

 

if you can ask then to get to this folder and get the backup of the branch in this folder , this would give you the branch back

in the stash server, go to this path

where 4927 is the repo id of my repo

you can find that in STASH login

 

data/repositories/4927/refs/heads

0 votes
Zakir Sikder Apr 18, 2016

Ok, great thanks! 

With the first step you mentioned, how to push the local copy to remote repo. 

Please advise. 

Rahul Mohan Apr 18, 2016

if you can find a person with the local copy you can run the below command

 

git checkout branch name

to be on the branch that needs to be pushed

git push -f origin/branchname

0 votes
Zakir Sikder Apr 18, 2016

git push remotes/origin/release/1.1.2 bugfix/XCPPP-1528-radius-no-protocol-or-message

fatal: 'remotes/origin/release/1.1.2' does not appear to be a git repository

fatal: Could not read from remote repository.

 

Please make sure you have the correct access rights (I have given the user write permission on the branch). 

and the repository exists.

Rahul Mohan Apr 18, 2016

this does not seem to look like a proper path to the branch

just try

git push origin branchname

Zakir Sikder Apr 18, 2016

Great, Thank you!

0 votes
Shamvil Raza Apr 18, 2016

The only possible way is to ask your fellow developer who might have that branch locally. 

Suggest an answer

Log in or Sign up to answer
This widget could not be displayed.
This widget could not be displayed.
Community showcase
Published in Bitbucket Pipelines

Building a Bitbucket Pipe as a casual coder

...ipe.sh :  #!/bin/bash source "$(dirname "$0")/common.sh" enable_debug extra_args="" if [[ "${DEBUG}" == "true" ]]; then extra_args="--verbose" fi # mandatory variables R...

1,865 views 1 19
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you