LIVE Instructor-Led Courses
Advanced Git and GitHub: Taking Your Skills to the Next Level

15 September 2023

Advanced Git and GitHub: Taking Your Skills to the Next Level

You've learned the basics on our Git for Beginners course- initialising repositories, making commits, creating branches, pushing to remote, and collaborating on GitHub. Now it's time to unlock more advanced Git capabilities to level up your version control skills.

This guide explores intermediate to advanced Git techniques for maximizing productivity. Follow along to master branching strategies, resetting commits, advanced collaboration, and other skills to boost your Git proficiency.

Leveraging Branches for Parallel Development

Branching unlocks parallel workflows in Git. Here are some best practices for an effective branching strategy:

  • Use feature branches for independent streams of work. Merge into main when ready to deploy.
  • Create a 'develop' branch to integrate features before releasing to 'main'.
  • Name branches semantically e.g. feature/login-module rather than cryptic names.
  • Delete merged branches to declutter. Prune old branches with git branch --merged | grep -v \* | xargs git branch -d
  • Protect the 'main' branch to control changes. Allow merging only after code review.
A successful Git branching model »

Rewriting Commit History with Rebase

Git rebase lets you reorder, squash, edit, or modify existing commits. For example:

# Interactive rebase git rebase -i HEAD~5 # Squash last 2 commits git rebase -i HEAD~2 # Reorder commits git rebase -i HEAD~5

This helps clean up local history before sharing branches. Use with caution - don't rebase public commits.

Git Reset vs Revert

git reset erases commits, moving the branch tip backwards. git revert preserves commit history by adding a new commit that reverts changes:

# Undo last commit, keep changes git reset HEAD~1 # Discard changes from last commit git reset --hard HEAD~1 # Create new commit undoing changes git revert HEAD~1

In most cases, prefer revert over reset to avoid losing data or rewriting public history.

Resetting, Checking Out & Reverting | Atlassian Git Tutorial

Cherry Picking Commits

Cherry picking lets you selectively apply commits from one branch to another:

# Apply commit <commit-hash> onto current branch git cherry-pick <commit-hash> # Cherry pick multiple commits git cherry-pick <commit-1> <commit-2>

This is useful for moving specific changes between branches.

Collaborating with Git Remotes

Remotes connect your local repository with shared counterparts like GitHub:

# Add remote repo git remote add <name> <url> # Fetch latest changes git fetch <remote> # Merge remote branch git merge <remote>/<branch> # Rebase on top of remote git rebase <remote>/<branch>

Use git remote -v to list configured remotes. origin refers to the default remote.

5 Session 5: Git Collaboration and Conflict Management | Reproducible  Research Techniques for Synthesis



With these intermediate skills, you can achieve efficient parallel development, undo mistakes, integrate work and share repositories.

For more advanced techniques, explore Git hooks, submodules, rebasing vs. merging, Git blame and bisect, logging, stash, patches and more.

The official Git docs are a fantastic resource for leveling up Git mastery. Keep learning - there's always more to uncover with Git!

Our previous article is Git and GitHub for Beginners: A Step-by-Step Guide or check out our article Learn Git and GitHub with these 10 Essential Commands or you might like to take one of our courses in Git and Github

+44 (0)20 8446 7555

[email protected]



Copyright © 2023 JBI Training. All Rights Reserved.
JB International Training Ltd  -  Company Registration Number: 08458005
Registered Address: Wohl Enterprise Hub, 2B Redbourne Avenue, London, N3 2BS

Privacy Policy | Terms & Conditions | Contact Us


Rust training course                                                                          React training course

Threat modelling training course   Python for data analysts training course

Power BI training course                                   Machine Learning training course

Spring Boot Microservices training course              Terraform training course

Kubernetes training course                                                            C++ training course

Power Automate training course                               Clean Code training course