Reputation: 8098
Just created a new branch in Bitbucket but I can see it neither in sourcetree nor using the git branch -r
command. Why do you think that is? Why I can't see that branch?
Do I need at least 1 commit on this fresh branch to see it in the remote list?
After creating the remote branch (from branch X) I did:
git pull origin X
git fetch --all
git remote update
I also did git config -e
fetch is defined as below for remote X:
[remote "origin"]
fetch = +refs/heads/*:refs/remotes/origin/*
None of them worked. That fresh branch is still invisible.
Upvotes: 3
Views: 1907
Reputation: 4333
Please follow the below steps:
Step 1: After creating new branch run this command from project directory (if you change directory earlier)
git fetch && git checkout <new_branch_name>
Step 2:
git add .
Step 3:
git commit -m "write your commit"
Step 4:
git push origin <new_branch_name>
Upvotes: 0
Reputation: 1323145
[remote "X"]
If your remote is named X
(like your branch), no amount of fetch
or pull origin
will fetch or pull anything from remote "X".
Even git fetch X
might not fetch anything if you have no remote "origin
" (and the refspec associate with remote X
is refs/remotes/origin/*: if you don't have an origin
...)
Type git remote -v
and check if origin
is actually referencing the right repo.
If you do, git config --local --edit
will allow you to go and change your config, fixing the discrepancy between the name of the remote and the refspec.
A git ls-remote | grep X
can help detect if the branch actually does exist.
Upvotes: 1
Reputation: 8098
Ok, I found the problem. The problem was actually about my being careless. The branch is created in the remote branch but I was not paying attention to the "Branch type" parameter while creating the branch in Bitbucket. git branch -r
was listing all the branches on the remote alphabetically and I was trying to see my branch among the "feature/..." branch list but I had not created the brach as a "feature" branch type, I had created is as a "custom" branch type and it was being listed towards the top of a huge branch list without feature/ prefix. Thanks, @VonC for all the help.
Upvotes: 1
Reputation: 106
You may please try to push your branch to upstream using :
git push -u origin X
Upvotes: -1