10 useful git aliases

Поделиться
HTML-код
  • Опубликовано: 6 июн 2024
  • Learn how to use git much faster with useful shortcuts.
    Use the following command to change your default editor to VSCode:
    git config --global core.editor "code --wait"
    If you use a different editor, just Google "git set text editor to $yourEditor", it's usually easy to find.
    After that you can use the following command to open the global config:
    git config --global --edit
    There, you can paste the commands from below.
    Here is the full list of aliases from this video:
    [alias]
    st = status -s
    sta = status
    conf = config --global --edit
    cge = config --global --edit
    ci = commit
    co = checkout
    cod = checkout .
    rh = reset HEAD
    aa = add -A
    cdf = clean -df
    br = branch
    bra = branch -a
    pr = pull --rebase
    amend = commit -a --amend --no-edit
    ciam = commit -a --amend --no-edit
    If you'd like to set up individual commands, you can also just paste these in your terminal:
    git config --global alias.st "status -s"
    git config --global alias.sta "status"
    git config --global alias.conf "config --global --edit"
    git config --global alias.cge "config --global --edit"
    git config --global alias.ci "commit"
    git config --global alias.co "checkout"
    git config --global alias.cod "checkout ."
    git config --global alias.rh "reset HEAD"
    git config --global alias.aa "add -A"
    git config --global alias.cdf "clean -df"
    git config --global alias.br "branch"
    git config --global alias.bra "branch -a"
    git config --global alias.pr "pull --rebase"
    git config --global alias.amend "commit -a --amend --no-edit"
    git config --global alias.ciam "commit -a --amend --no-edit"
    Video contents:
    0:00 - Why aliases?
    0:44 - Command Line vs GUI
    1:46 - git status
    2:10 - Setting your text editor
    3:00 - Editing the global config
    3:20 - git commit & checkout
    4:15 - git reset HEAD
    5:12 - Adding all changes
    5:30 - git clean
    5:48 - git pull --rebase
    6:17 - git branch
    6:27 - git commit --amend
    7:24 - Full list of aliases
    LEGAL DISCLAIMER
    ▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
    Everything here is for informational purposes only. All non-licensed clips used for fair use commentary, criticism, and educational purposes. See Hosseinzadeh v. Klein, 276 F.Supp.3d 34 (S.D.N.Y. 2017); Equals Three, LLC v. Jukin Media, Inc., 139 F. Supp. 3d 1094 (C.D. Cal. 2015).
  • НаукаНаука

Комментарии • 74

  • @joshuagauss8179
    @joshuagauss8179 25 дней назад +21

    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  25 дней назад

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

    • @vinicchleme
      @vinicchleme 19 дней назад +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 6 часов назад

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

  • @7empestx
    @7empestx 25 дней назад +17

    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  25 дней назад

      Yeah, git stash is super useful :)

    • @mrAjor
      @mrAjor 21 день назад +1

      Maybe try git worktree

  • @suparno2
    @suparno2 18 дней назад +2

    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  18 дней назад

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

  • @ethanjoyner
    @ethanjoyner 25 дней назад +6

    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!

  • @AndyP3r3z
    @AndyP3r3z 20 дней назад +1

    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!

  • @daehxxiD
    @daehxxiD 18 дней назад

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

  • @oceannuclear
    @oceannuclear 24 дня назад

    That's a really well produced video! Thanks!

  • @markuszuegg8256
    @markuszuegg8256 25 дней назад +1

    the best new yt find, love the vids!

  • @ThienLe-po5nc
    @ThienLe-po5nc 17 дней назад

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

  • @user-xt1ko6zv4n
    @user-xt1ko6zv4n 25 дней назад

    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 :)

  • @juandavidramirezalvarez3807
    @juandavidramirezalvarez3807 25 дней назад

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

  • @kirillzlobin7135
    @kirillzlobin7135 25 дней назад

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

  • @williamcoarsey5222
    @williamcoarsey5222 24 дня назад

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

  • @krissh_the_dev
    @krissh_the_dev 24 дня назад

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

  • @wingflanagan
    @wingflanagan 23 дня назад

    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  21 день назад +1

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

  • @vinicchleme
    @vinicchleme 19 дней назад

    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  19 дней назад +1

      This is a really nice one, thanks for sharing!

  • @theoneandonlyskinnyb
    @theoneandonlyskinnyb 21 день назад +1

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

    • @philomatics
      @philomatics  21 день назад +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 25 дней назад

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

  • @kirillzlobin7135
    @kirillzlobin7135 25 дней назад +2

    Continue doing your great job, maan

    • @bobDotJS
      @bobDotJS 25 дней назад

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

  • @siricecream17
    @siricecream17 22 дня назад +2

    another banger video! are these coming regulary now?

    • @philomatics
      @philomatics  21 день назад +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 ;)

  • @AleksandarV_
    @AleksandarV_ 24 дня назад

    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  24 дня назад +4

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

  • @djsheets
    @djsheets 18 дней назад

    nice vid again, keep them coming!

  • @peter_hauer
    @peter_hauer 25 дней назад +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  25 дней назад

      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 25 дней назад

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

  • @jamesshockley4317
    @jamesshockley4317 24 дня назад

    Thank you again, based Phil

  • @dmitrytomashevich4344
    @dmitrytomashevich4344 24 дня назад

    Thanks for you videos

  • @TheBrunoRM
    @TheBrunoRM 24 дня назад

    I really like your videos!!

  • @shakirahsanromeo7863
    @shakirahsanromeo7863 25 дней назад

    Very useful. Thanks

  • @felipheleal
    @felipheleal 19 дней назад

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

    • @philomatics
      @philomatics  19 дней назад

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

  • @ExotErr
    @ExotErr 25 дней назад

    Great videos, keep it up

  • @test9828alpha
    @test9828alpha 5 дней назад

    best git content on the www

  • @berk_karaal
    @berk_karaal 20 дней назад

    A detailed git stash video would be nice

  • @antonzimin3999
    @antonzimin3999 19 дней назад

    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  19 дней назад

      Cool tip, thanks for sharing!

  • @krateskim4169
    @krateskim4169 23 дня назад

    i like to know about git stash in a future video

  • @kauai9763
    @kauai9763 21 день назад

    I would love buying an course of yours

  • @Lunolux
    @Lunolux 24 дня назад

    nice video, i never use amend, stash

  • @cccccc864
    @cccccc864 20 дней назад +1

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

    • @philomatics
      @philomatics  20 дней назад +2

      Thanks! Got stuff in the works on that!

  • @alexandreduhaime8622
    @alexandreduhaime8622 17 дней назад

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

  • @bobDotJS
    @bobDotJS 25 дней назад

    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  24 дня назад +1

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

    • @bobDotJS
      @bobDotJS 11 дней назад

      ​@@philomatics my man! Watching it now!

  • @mohammedaminelm7836
    @mohammedaminelm7836 20 дней назад +1

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

    • @philomatics
      @philomatics  20 дней назад +1

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

    • @mohammedaminelm7836
      @mohammedaminelm7836 20 дней назад

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

  • @tfld
    @tfld 23 дня назад

    I'd like a video about stash

  • @cpbpilot
    @cpbpilot 24 дня назад

    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  24 дня назад

      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 :)

  • @karlson2804
    @karlson2804 22 дня назад

    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  21 день назад

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

  • @atom8861
    @atom8861 19 дней назад

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

  • @carstenschlegel6975
    @carstenschlegel6975 23 дня назад

    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  21 день назад

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

  • @asdfg_qwert
    @asdfg_qwert 21 день назад

    git rebase -i

    • @philomatics
      @philomatics  21 день назад

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

  • @Excalibaard
    @Excalibaard 22 дня назад

    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  21 день назад +1

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