You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If you want to check whether a local branch exists, you DON'T call Repository.Branch(name string) which returns a *config.Branch representing a branch in .git/config, which is a dead end.
Instead, you NEED to call Repository.Branchs() which returns a storer.ReferenceIter. Then you can call its ForEach to iterate and compare every Reference.Name() to get the result you want.
If you want to check whether a local branch exists, you DON'T call
Repository.Branch(name string)
which returns a*config.Branch
representing a branch in.git/config
, which is a dead end.Instead, you NEED to call
Repository.Branchs()
which returns astorer.ReferenceIter
. Then you can call itsForEach
to iterate and compare everyReference.Name()
to get the result you want.Here is an example:
It took me a while to figure this out. Hope it helps.
The text was updated successfully, but these errors were encountered: