Showing posts with label branch. Show all posts
Showing posts with label branch. Show all posts

Thursday, 1 December 2022

Git 2.23 Adds Switch and Restore Commands

Just a little blurb from me on how to deal with branches with the "switch" command. I was still used to the "checkout" command.

# show all branches
git branch            
  
# create local branch from integration, and switch
git switch -c integration origin/integration
 
# switch back to the master
git switch master  
 
# switch to integration
git switch integration
  
# remove old local branch v0.0.1
git branch -d v0.0.1

References

InfoQ - Git 2.23 Adds Switch and Restore Commands
https://www.infoq.com/news/2019/08/git-2-23-switch-restore/

Thursday, 31 January 2019

Git Branches

Just a little something for me to remember how to create branches and how to switch over to them.

There are plenty of resources available explaining how to do this, so I just thought I'd write some references down here.

$ git branch testing
creates a new branch called testing. Notice that this does not automatically make your new branch the current HEAD.
$ git log --oneline --decorate
seeing the branches in your log (as well as tags and the origins. Nice.)
54718edb (HEAD -> master, tag: v2.0.0, origin/master, origin/HEAD, v2.0.1) /* notes here. */
4c8c3bb9 /* moved the entire karchanangular into karchanpersonal. It compiles into the webapp directory. */
bb4bb432 /* upgrade from angular 4 to angular 7 */
12b528ed /* removed old directories that are no longer in use. Clean up. */
ead93fc3 /* changed images table, now has an autogenerated ID, plus an index on the pair owner and url. */
$ git checkout testing
switching to a branch
$ git checkout -b testing
shorthand for both creating a new branch called testing and checking it out immediately.
$ git checkout master ; git merge testing
merges the changes in the testing branch over into the master.
$ git checkout testing ; git merge master
merge the changes from your master into your testing branch.
$ git branch -d testing
delete a branch
$ git status
also shows you what branch you are on.
$ git show-branch
shows you all existing branches, and the commit that goes with that point in which it was branched.

References

GitBook - Git Branching
https://git-scm.com/book/en/v2/Git-Branching-Branches-in-a-Nutshell
Git - Branch Manpage
https://git-scm.com/docs/git-branch
TutorialsPoint - Git Managing Branches
https://www.tutorialspoint.com/git/git_managing_branches.htm