💾 Archived View for zigford.org › git---working-with-branches.gmi captured on 2023-07-10 at 13:31:34. Gemini links have been rewritten to link to archived content
⬅️ Previous capture (2023-03-20)
-=-=-=-=-=-=-
Sharing linux/windows scripts and tips
August 06, 2019 — Jesse Harris
In this quick article, I will:
~~~
Reminder - This site is mainly for my memory and reference. You can find this information anywhere out on the web, but I find the best way to remember something is to write it down yourself.
Firstly, clone a repo and cd into it.
make a new local branch
git checkout -b updates/onedrive
Now, make some commits and we will push this to a new remote branch like this:
push to remote branch
git push -u origin updates/onedrive
note, the remote and local branch names need not match
second note, -u stands for --set-upstream-to
Next, go to another computer where you will resume work. (or for the sake of practice, just clone again to another directory) On the new clone, we need to fetch all other branches
download all branches
git fetch origin
create a local branch, pull the remote branch to it
git checkout -b updates/onedrive git pull origin updates/onedrive
Here we can examine the branch, continue to make changes and commits. If we want to push back to the remote branch, we need to set the upstream:
git push -u origin updates/onedrive
When we are done, perhaps we want to merge the changes back to master. In that case:
merge changes to master
git checkout master git merge updates/onedrive
Now would be a good time to push changes. Then you can delete the local and remote branches.
delete local branch
git branch -d updates/onedrive
delete remote branch
git push --delete origin updates/onedrive
I hope this information helps me, let alone you!
Helpful links
Tags:
Generated with bashblog, a single bash script to easily create blogs like this one