My most used git aliases

Поділитися
Вставка
  • Опубліковано 20 вер 2024

КОМЕНТАРІ • 91

  • @joshuagauss8179
    @joshuagauss8179 4 місяці тому +35

    My favorites I use daily:
    - git fop = git fetch origin --prune
    - git mofo = git merge origin/master --ff-only
    - git edit = git commit --amend
    - git forgot = git edit --no-edit
    - git hist = git log --one-line -10
    - git dw = git diff -w
    - git dws = git dw --staged
    - git swh = git show -w HEAD
    I also use it for common mistakes I make while typing the commands:
    - git rbanch = git branch
    - git stats = git status

    • @philomatics
      @philomatics  4 місяці тому +2

      Oh man I'm gonna steal fop, that's really useful. Thanks for posting these!

    • @vinicchleme
      @vinicchleme 4 місяці тому +1

      When it comes to command typos, you can configure `help.autocorrect` to use a suggested command automatically. You would have to set a timer, so with `git config --global help.autocorrect 20` it will enable auto-correct and suggested commands will run after 2 seconds (1 would be 100ms). So if you want your command mistakes to still work without having to create a bunch of aliases, this is a nice way to do it.

    • @oconsertador9021
      @oconsertador9021 3 місяці тому

      What about "git lsc" as an alias for "git status"?
      ("lsc" for "list changes")

    • @0xshashwat
      @0xshashwat Місяць тому

      I use fap : fetch --all --prune 😂

  • @suparno2
    @suparno2 4 місяці тому +18

    I almost never comment on videos, but I have to do so here. Your content, production quality, edit, and voice-over are brilliant. You should really make more videos.

    • @philomatics
      @philomatics  4 місяці тому

      Thank you so much for the nice comment! New video coming later today! :)

    • @CoronaWolle
      @CoronaWolle 3 місяці тому

      Couldn't agree more. The topics covered so far may be basic, but super useful. @philomatics please keep educating the masses

  • @7empestx
    @7empestx 4 місяці тому +20

    I use git stash all the time, especially when switching between branches for doing code reviews. I'll start working on a new feature on a feature branch, and if I need to fix a bug in my code review on another branch, I'll do a git stash, git checkout other branch, fix bug, git checkout feature branch, then a git stash pop

    • @philomatics
      @philomatics  4 місяці тому +1

      Yeah, git stash is super useful :)

    • @mrAjor
      @mrAjor 4 місяці тому +3

      Maybe try git worktree

  • @AndyP3r3z
    @AndyP3r3z 4 місяці тому +4

    Just 2 videos and I learned a lot about git. I just started to use it and it's super helpful!
    PS.: For every "Let me know in the comments if you'd like a full video..." I'm saying yes!

  • @vinicchleme
    @vinicchleme 4 місяці тому +1

    If I need to force push something, I use the alias `lease = push --force-with-lease --force-if-includes` to have a very safe way to do it. In short, it will abort if there are any new changes in the remote, so it avoids deleting another person's pushed commits. It ensures that any updates from the remote have been incorporated locally by rejecting the forced update if that is not the case.
    I used to only use `force-with-lease` and never needed `force-if-includes`, but since I'm using an alias either way, might as well use both.

    • @philomatics
      @philomatics  4 місяці тому +1

      This is a really nice one, thanks for sharing!

  • @ethanjoyner
    @ethanjoyner 4 місяці тому +9

    This is really cool content, I've always wanted to do better in my git usage as a student so I don't bring any bad habits or practices into an actual collaborative project. I'm going to tell my friends to watch ur videos for tips and tricks!

  • @Undrios
    @Undrios 2 місяці тому +2

    omg this video is a gem 💎💎💎💎💎💎💎
    for me i use *PowerShell* aliases :
    gco branchName -> git chechout branchName
    gsw branchName -> git switch branchName
    gsta -> git status
    gst -> git status -s
    gbr -> git branch
    how to do it:
    1- open PowerShell
    2- run -> vim $PROFILE (it opens powershell profile file for configuratoin in vim)
    (if you are not using vim : run -> echo $PROFILE ,this will print the path of the file and open it with any text editor)
    3 - past this :
    function gco($branchName) { git checkout $branchName }
    function gsw($branchName) { git switch $branchName }
    function gsta { git status }
    function gst { git status -s }
    function gbr { git branch }

    • @philomatics
      @philomatics  2 місяці тому +1

      Thanks for the nice comment and the tips for PowerShell, super helpful for Windows users!

  • @ThienLe-po5nc
    @ThienLe-po5nc 4 місяці тому +1

    A video about git amend?! Hell yes, git amend is surely one of my favorites.

  • @НазарПанасюк-у8я
    @НазарПанасюк-у8я 4 місяці тому +1

    good video as before. but the previous one was *fire*! because you took one single tip and explained it in great detail with animations and visualisation! THAT was the kill feature. the visualization!
    one small animation can explain more than a 1000 words.
    i know that it means more work and effort for you, but it works better for viewers than anything else.
    thanks for the work!
    looking forward for more :)

  • @daehxxiD
    @daehxxiD 4 місяці тому

    This is exactly the content someone getting into programming needs. Thanks so much for this!

  • @peter_hauer
    @peter_hauer 4 місяці тому +1

    Great videos. In my opinion beginners struggle the most with reverting changes and with merges. In my opinion one of the most beneficial aliases is to do some graphical branch visualization like „git log --graph --decorate --oneline“ and similar. I see a lot of colleagues using extensions, tools like SourceTree or gitk or representations in Gitlab to display that, but then you always have to switch tools. In my opinion it is great that you can get the same in git-terminal.

    • @philomatics
      @philomatics  4 місяці тому

      Thanks for the kind words and the suggestions!
      Hmm, I do think that the CLI representation of the branching structure is a bit difficult to interpret, especially for beginners. I myself prefer using GUIs.
      If you put the gui in your path I think the tool switching isn't too bad - I use 'stree .' all the time to launch SourceTree from the current repo.

    • @peter_hauer
      @peter_hauer 4 місяці тому

      @@philomatics If you are in vscode then I know that "Git Graph" as an extension is quite popular here and for the merges BeyondCompare.

  • @ELStalky
    @ELStalky Місяць тому

    The two alises I use the most:
    fetcho = fetch origin master:master [pulls remote master changes into local master while being on feature branch, usually followed by a merge]
    pulls = !git stash && git pull && git stash pop [when local changes prevent a pull]

    • @philomatics
      @philomatics  Місяць тому +1

      Thanks for sharing!
      Hah, fetcho is fun to say ;)
      For `pulls` google the autostash setting, I think it might be super useful for you!

    • @ELStalky
      @ELStalky Місяць тому

      @@philomatics Didn't know that one, thanks :)

  • @hazh9936
    @hazh9936 3 місяці тому

    Idk why but I love these kind of videos. I watch them during lunch. Great job!
    I’d also like to see more videos about useful linux commands/shortcuts.

    • @philomatics
      @philomatics  3 місяці тому

      Thanks for the suggestion! I'll consider it!

    • @philomatics
      @philomatics  3 місяці тому

      And thanks for the kind words :) Keeps me wanting to make more :)

  • @wingflanagan
    @wingflanagan 4 місяці тому

    OK. You have my subscription. I've been using Git for many years and you just made me feel like a newbie. I might make this required viewing for my team.

    • @philomatics
      @philomatics  4 місяці тому +1

      Wow, that's super nice to hear, thank you!

  • @AleksandarV_
    @AleksandarV_ 4 місяці тому

    Since you are using those aliases in the command line, you can even register them in it's configuration (.bashrc etc).
    Inside corresponding configuration file:
    alias gcm='git commit -m'
    alias gs='git status'
    alias s='git status'
    It's a preference thing, but by doing so, `git st` will become `gs` or even `s`.
    By the way, loving your vids, keep it up!

    • @philomatics
      @philomatics  4 місяці тому +4

      That's cool! I personally prefer keeping each tool separate, but if you like this, it definitely works!

  • @berk_karaal
    @berk_karaal 4 місяці тому +1

    A detailed git stash video would be nice

  • @kirillzlobin7135
    @kirillzlobin7135 4 місяці тому +2

    Continue doing your great job, maan

    • @bobDotJS
      @bobDotJS 4 місяці тому

      He is but you didn't have to say it like a sheep!

  • @Bsunders
    @Bsunders 4 місяці тому +1

    the best new yt find, love the vids!

  • @kirillzlobin7135
    @kirillzlobin7135 4 місяці тому

    Just found your channel. And started watching this new video that you added few minutes ago :)

  • @oceannuclear
    @oceannuclear 4 місяці тому

    That's a really well produced video! Thanks!

  • @emnul8583
    @emnul8583 24 дні тому

    def would like to learn more about amending commits

  • @siricecream17
    @siricecream17 4 місяці тому +2

    another banger video! are these coming regulary now?

    • @philomatics
      @philomatics  4 місяці тому +1

      Thanks for the kind words!
      Yep! Original plan was to release one every Monday but these take 30+ hours to create. So let's see how long I can keep it up or at what frequency I'm going to arrive at ;)

  • @williamcoarsey5222
    @williamcoarsey5222 4 місяці тому

    Great content, I would love to see you make more on git and other development tools.

  • @cccccc864
    @cccccc864 4 місяці тому +2

    Merge, rebase, squash maybe? I always have a hard time wrapping my head around them.

    • @philomatics
      @philomatics  4 місяці тому +3

      Thanks! Got stuff in the works on that!

  • @rainymatch
    @rainymatch 4 місяці тому

    nice vid again, keep them coming!

  • @girondavidfour
    @girondavidfour 4 місяці тому

    Thanks for explaining, very clever approaching to the point. Keep it up!

  • @antonzimin3999
    @antonzimin3999 4 місяці тому

    You can restore a file deleted with 'git clean'. When using VSCode, create an empty file with the same name, then select this file in the Explorer, and click the 'Timeline' tab at the bottom left to see all changes for this file.

    • @philomatics
      @philomatics  4 місяці тому

      Cool tip, thanks for sharing!

  • @theoneandonlyskinnyb
    @theoneandonlyskinnyb 4 місяці тому +1

    We use a lot of submodules for shared libraries, so I use git subs = submodule update --init --recursive

    • @philomatics
      @philomatics  4 місяці тому +2

      I got that one too! Didn't wanna include it in the video because it would've been too long to explain, but I might do one on submodules at some point.

  • @w1atrak1ng
    @w1atrak1ng 4 місяці тому

    Cool two videos on your channel, I like 7min duration

  • @rafaelortega1376
    @rafaelortega1376 20 днів тому

    Really good. Subscribed

  • @siuyutpang2335
    @siuyutpang2335 26 днів тому

    Actually, you can use git reset --hard HEAD implement both git reset HEAD and git checkout

  • @test9828alpha
    @test9828alpha 3 місяці тому +1

    best git content on the www

  • @yrtepgold
    @yrtepgold 3 місяці тому

    You have an opportunity to make your videos more inclusive by having your examples include a main branch instead of master

    • @philomatics
      @philomatics  3 місяці тому +1

      Hey, thanks for your suggestion! I did use master at one point in the video, but only to show how sometimes people are confused because they're used to pushing to master, when now it's called main. But I'm totally onboard with you!

  • @krissh_the_dev
    @krissh_the_dev 4 місяці тому

    Very useful video. Thank you. Keep up the good work.

  • @felipheleal
    @felipheleal 4 місяці тому

    Cool content
    Where did you edit your video?
    Excellent edit also

    • @philomatics
      @philomatics  4 місяці тому

      Edited in Camtasia :) Thanks for the super nice comment, made my day :)

  • @Lunolux
    @Lunolux 4 місяці тому

    nice video, i never use amend, stash

  • @kauai9763
    @kauai9763 4 місяці тому

    I would love buying an course of yours

  • @jamesshockley4317
    @jamesshockley4317 4 місяці тому

    Thank you again, based Phil

  • @alexandreduhaime8622
    @alexandreduhaime8622 4 місяці тому

    4:58 You can use "git reset --hard HEAD" to reset all the files including the staged ones

  • @bobDotJS
    @bobDotJS 4 місяці тому

    I'd love a video about fixing merge errors. I do it constantly at work but it's always difficult. There's got to be some trick I don't know. I use VS code as my editor and it surely has a good process for this that I just never learned.

    • @philomatics
      @philomatics  4 місяці тому +1

      I'm working on this exactly! What kinds of problems do you run into when you merge?

    • @bobDotJS
      @bobDotJS 3 місяці тому

      ​@@philomatics my man! Watching it now!

  • @krateskim4169
    @krateskim4169 4 місяці тому

    i like to know about git stash in a future video

  • @tfld
    @tfld 4 місяці тому

    I'd like a video about stash

  • @karlson2804
    @karlson2804 4 місяці тому

    Just need to have a good video about correct workflow on GitHub and Git to manege big project with 2-3 people for exemple.

    • @philomatics
      @philomatics  4 місяці тому

      Thanks for the suggestion! Might do a video on branching structure soon so stay tuned!

  • @carstenschlegel6975
    @carstenschlegel6975 4 місяці тому

    alias for git log (git l) and git log --all (git la) with own format:
    l = log --graph --abbrev-commit --decorate --format=format:'%C(bold blue)%h%C(reset) - %C(bold green)(%ar)%C(reset) %C(white)%s%C(reset) %C(dim white)- %an%C(reset)%C(auto)%d%C(reset)'
    la = log --graph --abbrev-commit --decorate --format=format:'%C(bold blue)%h%C(reset) - %C(bold green)(%ar)%C(reset) %C(white)%s%C(reset) %C(dim white)- %an%C(reset)%C(auto)%d%C(reset)' --all

    • @philomatics
      @philomatics  4 місяці тому

      Oh that's pretty cool! Might steal that for a follow up video at some point, thanks for sharing!

  • @shakirahsanromeo7863
    @shakirahsanromeo7863 4 місяці тому

    Very useful. Thanks

  • @cpbpilot
    @cpbpilot 4 місяці тому

    I would love to see a video about fixing git errors, I got this error and have never been able to fix it. “warning: Pulling without specifying how to reconcile divergent branches is
    discouraged. You can squelch this message by running one of the following
    commands sometime before your next pull:
    git config pull.rebase false # merge (the default strategy)
    git config pull.rebase true # rebase
    git config pull.ff only # fast-forward only
    You can replace "git config" with "git config --global" to set a default
    preference for all repositories. You can also pass --rebase, --no-rebase,
    or --ff-only on the command line to override the configured default per
    invocation.”
    I had made commits to the same branch on different computers I was able to push one to the origin but the. On the other computer I tried to do a pull and got the error above. I tried the 3 suggestions and was not able to get them to work. The only way I got back to a working state was deleting the repo on the second computer and recloning it back down.

    • @philomatics
      @philomatics  4 місяці тому

      Thanks for the suggestion! Might do a video on that in the future :)
      Not sure what happened there in the repo, but I'd suggest running `git config --global pull.rebase false`.
      This will set the default pull strategy to 'merge', which was the default in git for a long time. Then refer to my other video to help you decide whether you want to use the default pull or pull --rebase in the future.
      Let me know if that helps or if you have any follow-up questions :)

  • @dmitrytomashevich4344
    @dmitrytomashevich4344 4 місяці тому

    Thanks for you videos

  • @ExotErr
    @ExotErr 4 місяці тому

    Great videos, keep it up

  • @TheBrunoRM
    @TheBrunoRM 4 місяці тому

    I really like your videos!!

  • @mohammedaminelm7836
    @mohammedaminelm7836 4 місяці тому +1

    Could please you tell me which tool you use for your animations🙏?

    • @philomatics
      @philomatics  4 місяці тому +1

      In this video it's just video editing software (Camtasia). In my first one it was Motion Canvas.

    • @mohammedaminelm7836
      @mohammedaminelm7836 4 місяці тому

      @@philomatics Thank you so much! You're doing a great job by the way👍✌️

  • @atom8861
    @atom8861 4 місяці тому

    Your content is great, and your style is really nice and clean. Like and sub from me! Can't wait to see more videos.

  • @asdfg_qwert
    @asdfg_qwert 4 місяці тому

    git rebase -i

    • @philomatics
      @philomatics  4 місяці тому

      Thanks for the suggestion! Video on rebasing is in the works!

  • @Excalibaard
    @Excalibaard 4 місяці тому

    0:10 The keyboard was in fact not 10-keyless, it had the numpad in plain view. 0/0 fake channel never subscribe

    • @philomatics
      @philomatics  4 місяці тому +1

      Ah damn you're absolutely right! Should've filmed my own instead of using stock footage. Video ruined.