Andrea Daly : Pull from an existing Remote Feature Branch - Option B

[setup]

mkdir <project-dir>

cd <project-dir>

git init

[configure remote origin #connecting to remote]

[pre-requisite: setup]

[ensure any existing local changes on master are pushed or stashed so working dir is clean]

git fetch -all

OR

git fetch <exististing-remote-feature-branch>

git pull origin master

git branch -r

 

[Illustrating detached HEAD scenario]

[integrate remote branch with local repo, detaches HEAD will get message]

git checkout <existing-remote-feature-branch>

[example : git checkout origin/feature-a]

 

[make local feature branch from ref created above, updates HEAD, points to remote branch]

<git checkout -b <new-local-feature-branch>

[example: git checkout -b feature-a]

 

[make and commit changes]

[push local changes to set up remote tracking branch]

git push -u origin <new-local-feature-branch>

[example: git push -u origin feature-a]

 

[now branch is  tracked, subsequent push to remote is: ]

git push

 

[verify  remote tracking branch]

git branch -vv