13 Advanced (but useful) Git Techniques and Shortcuts

876,394
0
Published 2021-09-07
Productive programmers tend to be really good at Git. Take a look at 13 advanced git tips and tricks to supercharge your development workflow. 🔥 Enroll in the New Full Git Course fireship.io/courses/git/

💰 Extra big 40% discount (expires in 1 week). Use code: oqBi9fWv
Upgrade to PRO at fireship.io/pro

#git #learntocode #tips

🔗 Resources

The Full Git & GitHub Course fireship.io/courses/git/
Git Docs git-scm.com/
Git in 100 Seconds    • Git Explained in 100 Seconds  

📚 Chapters

00:00 Git Started
00:59 Combine add & commit
01:20 Aliases
01:38 Amend
02:03 Force Push
02:24 Revert
02:47 Codespaces
03:21 Stash
04:05 PC Master Branch
04:27 Pretty Logs
04:51 Bisect
05:14 Autosquash
06:18 Hooks
06:58 Destroy Things
07:41 Checkout to Last


🎨 My Editor Settings

- Atom One Dark
- vscode-icons
- Fira Code Font

🏷️ Topics Covered

- Git Shortcuts
- Github Codespaces Cloud VSCode
- Software Version Control
- Dealing with Merge Conflicts
- Git Merge & Rebase
- How to Squash C

All Comments (21)
  • The guy who created git seems really smart. He should create a kernel someday.
  • @vim_programar
    Good tip, do not use —force, this will make all your coworkers hate you, use —force-with-lease, this will only allow you to push the code if there are no conflicting changes with the current parent branch 👌
  • @leoaso6984
    Important note: "git commit -a" will only automatically add changes to files git is already tracking. If you create a new file, you still need to "git add" it.
  • @technikhil314
    alias uncommit="git reset HEAD~1" alias recommit="git commit --amend --no-edit" alias editcommit="git commit --amend" These are my all time favorite aliases
  • @technomunk
    Instead of showing "--force" flag you should default to "--force-with-lease" which will avoid pushing the code if it would overwrite something you didn't anticipate (coworker's code)
  • @lbedoya13
    3:21 ah yes, stash: "That's the code the project deserves, but not the one we need right now"
  • @Arrviasto
    The most useful git technique I've learned is understanding how it works internally (what is a commit and how it is stored, that a branch is pretty much a pointer to a commit etc). This allows for much more flexibility when it comes to managing your local repo. At work I'm constantly juggling commits between local branches, mixing and squashing them as I need them to. There is no problem in running cherry-pick on a branch to get its' top commit or pushing your previous commit to remote while current one is not ready. And also reflog.
  • Let's take a moment to appreciate how this guy drops amazing content every other day. St. Fireship
  • @NomadicJulien
    git switch: move your current changes to another branch. I regularly work on the main branch and then switch those untracked changes to a new branch then I commit them. The perfect use case is when you just want to test something, but you're not sure it's worth it. > git switch -c''
  • @Sam-qn4ly
    Master will always be my main branch, It’s the master copy.
  • @TheBoab400
    I don't watch Fireship videos that often, but when I do they always blow my mind. Like, I need to watch them over & over to absorb all the things that are in them. Thank you so much for this, we developers need to master GIT for sure.
  • @DevAmateur
    Extremely well explained video and added new stuff I did not know. The master rename to main is the stupidest thing I have ever felt in person about this new vibe of racism and sexism. It is ridiculous.
  • @gesit7120
    git bisect blew my mind. I don't think I will need it in the future, but I love that this functionality exists
  • @troythompson2
    This was perfect Jeff. Being a pro member has really paid off. Keep up the great content my guy
  • @RobertBrunhage
    Amazing video once again! --force-with-lease is another awesome --force flag that reduces some of the risks regarding overwriting others changes 😎
  • @ezkymos
    6:55 there's also the python pre-commit to check coding style with clang-format before commit. Very useful to be sure the remote only have clean code
  • @ViieeS
    04:05 master branch renaming is so stupid 🤦🏻‍
  • 2:35 git revert does not "got back to the original state"; that's checkout / reset. git revert creates a new commit with the opposing changes effectively reverting the reverted commit (hence the name).
  • @MrAyush98
    That bonus tip in the end blew my mind!! The others you come across whenever you Google issues you have with git. But that last one saves so much time especially on terminals that don't have autocomplete.
  • @marco.garofalo
    One operation that I use quite a lot is "git add -p", which basically allows me to review each piece of code I changed/added/deleted in order to have more granular control over what I want to include in the next commit, and maybe squash the changes I didn't include, for later.