Git set tracking branch while offline -


git push -u origin branch

binds branch origin/branch subsequent pushes branch can git push, far understand.

can set kind of tracking brand new repo (origin/branch doesn't exist yet) while offline? want make subsequent pushes branch go origin/branch without me having specify when go online.

i'll use xyz name of branch , keep origin name of remote avoid confusion. mentioned online method push , set upstream @ same time..

git push --set-upstream origin xyz 

fetch online, set upstream offline

the preferred way fetch branch before going offline , using --set-upstream-to option of git branch set upstream without pushing.

git branch --set-upstream-to origin/xyz 

that results in adding following lines .git/config result of online way described before.

[branch "xyz"]     remote = origin     merge = refs/heads/xyz 

fully offline approach

when don't want fetch remote branch first, can either edit .git/config hand or use git config facility perform same action.

git config branch.xyz.remote origin git config branch.xyz.merge refs/heads/xyz 

when fetch remote branch, should have reached same result --set-upstream-to remote branch fetched.

alternative offline approach

you can instead mimic fetch offline setting remote branch ref specific commit, e.g. same commit local branch.

git update-ref refs/remotes/origin/xyz xyz git branch --set-upstream-to origin/xyz 

the idea of direct ref updating borrowed decave's answer. use care , read git-fetch(1) notes fast-forward/non-fast-forward fetches.


Comments

Popular posts from this blog

python - TypeError: start must be a integer -

c# - DevExpress RepositoryItemComboBox BackColor property ignored -

django - Creating multiple model instances in DRF3 -