10 useful git aliases

  Рет қаралды 10,813

Philomatics

Philomatics

Күн бұрын

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

Пікірлер: 80
@joshuagauss8179
@joshuagauss8179 Ай бұрын
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 Ай бұрын
Oh man I'm gonna steal fop, that's really useful. Thanks for posting these!
@vinicchleme
@vinicchleme 26 күн бұрын
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 7 күн бұрын
What about "git lsc" as an alias for "git status"? ("lsc" for "list changes")
@suparno2
@suparno2 25 күн бұрын
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 25 күн бұрын
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 Ай бұрын
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 Ай бұрын
Yeah, git stash is super useful :)
@mrAjor
@mrAjor 27 күн бұрын
Maybe try git worktree
@ethanjoyner
@ethanjoyner Ай бұрын
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 27 күн бұрын
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!
@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 :)
@markuszuegg8256
@markuszuegg8256 Ай бұрын
the best new yt find, love the vids!
@daehxxiD
@daehxxiD 24 күн бұрын
This is exactly the content someone getting into programming needs. Thanks so much for this!
@oceannuclear
@oceannuclear Ай бұрын
That's a really well produced video! Thanks!
@siricecream17
@siricecream17 29 күн бұрын
another banger video! are these coming regulary now?
@philomatics
@philomatics 28 күн бұрын
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 ;)
@juandavidramirezalvarez3807
@juandavidramirezalvarez3807 Ай бұрын
Thanks for explaining, very clever approaching to the point. Keep it up!
@ThienLe-po5nc
@ThienLe-po5nc 24 күн бұрын
A video about git amend?! Hell yes, git amend is surely one of my favorites.
@williamcoarsey5222
@williamcoarsey5222 Ай бұрын
Great content, I would love to see you make more on git and other development tools.
@krissh_the_dev
@krissh_the_dev Ай бұрын
Very useful video. Thank you. Keep up the good work.
@kirillzlobin7135
@kirillzlobin7135 Ай бұрын
Just found your channel. And started watching this new video that you added few minutes ago :)
@rainymatch
@rainymatch 24 күн бұрын
nice vid again, keep them coming!
@user-xt1ko6zv4n
@user-xt1ko6zv4n Ай бұрын
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 :)
@test9828alpha
@test9828alpha 12 күн бұрын
best git content on the www
@vinicchleme
@vinicchleme 26 күн бұрын
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 26 күн бұрын
This is a really nice one, thanks for sharing!
@kirillzlobin7135
@kirillzlobin7135 Ай бұрын
Continue doing your great job, maan
@bobDotJS
@bobDotJS Ай бұрын
He is but you didn't have to say it like a sheep!
@peter_hauer
@peter_hauer Ай бұрын
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 Ай бұрын
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 Ай бұрын
@@philomatics If you are in vscode then I know that "Git Graph" as an extension is quite popular here and for the merges BeyondCompare.
@wingflanagan
@wingflanagan Ай бұрын
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 28 күн бұрын
Wow, that's super nice to hear, thank you!
@TheBrunoRM
@TheBrunoRM Ай бұрын
I really like your videos!!
@theoneandonlyskinnyb
@theoneandonlyskinnyb 28 күн бұрын
We use a lot of submodules for shared libraries, so I use git subs = submodule update --init --recursive
@philomatics
@philomatics 28 күн бұрын
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.
@AleksandarV_
@AleksandarV_ Ай бұрын
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 Ай бұрын
That's cool! I personally prefer keeping each tool separate, but if you like this, it definitely works!
@dmitrytomashevich4344
@dmitrytomashevich4344 Ай бұрын
Thanks for you videos
@w1atrak1ng
@w1atrak1ng Ай бұрын
Cool two videos on your channel, I like 7min duration
@jamesshockley4317
@jamesshockley4317 Ай бұрын
Thank you again, based Phil
@felipheleal
@felipheleal 26 күн бұрын
Cool content Where did you edit your video? Excellent edit also
@philomatics
@philomatics 26 күн бұрын
Edited in Camtasia :) Thanks for the super nice comment, made my day :)
@ExotErr
@ExotErr Ай бұрын
Great videos, keep it up
@shakirahsanromeo7863
@shakirahsanromeo7863 Ай бұрын
Very useful. Thanks
@berk_karaal
@berk_karaal 27 күн бұрын
A detailed git stash video would be nice
@cccccc864
@cccccc864 27 күн бұрын
Merge, rebase, squash maybe? I always have a hard time wrapping my head around them.
@philomatics
@philomatics 27 күн бұрын
Thanks! Got stuff in the works on that!
@krateskim4169
@krateskim4169 Ай бұрын
i like to know about git stash in a future video
@antonzimin3999
@antonzimin3999 26 күн бұрын
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 26 күн бұрын
Cool tip, thanks for sharing!
@kauai9763
@kauai9763 28 күн бұрын
I would love buying an course of yours
@Lunolux
@Lunolux Ай бұрын
nice video, i never use amend, stash
@bobDotJS
@bobDotJS Ай бұрын
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 Ай бұрын
I'm working on this exactly! What kinds of problems do you run into when you merge?
@bobDotJS
@bobDotJS 17 күн бұрын
​@@philomatics my man! Watching it now!
@alexandreduhaime8622
@alexandreduhaime8622 24 күн бұрын
4:58 You can use "git reset --hard HEAD" to reset all the files including the staged ones
@mohammedaminelm7836
@mohammedaminelm7836 27 күн бұрын
Could please you tell me which tool you use for your animations🙏?
@philomatics
@philomatics 27 күн бұрын
In this video it's just video editing software (Camtasia). In my first one it was Motion Canvas.
@mohammedaminelm7836
@mohammedaminelm7836 27 күн бұрын
@@philomatics Thank you so much! You're doing a great job by the way👍✌️
@yrtepgold
@yrtepgold Күн бұрын
You have an opportunity to make your videos more inclusive by having your examples include a main branch instead of master
@philomatics
@philomatics 18 сағат бұрын
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!
@tfld
@tfld Ай бұрын
I'd like a video about stash
@atom8861
@atom8861 26 күн бұрын
Your content is great, and your style is really nice and clean. Like and sub from me! Can't wait to see more videos.
@cpbpilot
@cpbpilot Ай бұрын
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 Ай бұрын
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 29 күн бұрын
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 28 күн бұрын
Thanks for the suggestion! Might do a video on branching structure soon so stay tuned!
@carstenschlegel6975
@carstenschlegel6975 Ай бұрын
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 28 күн бұрын
Oh that's pretty cool! Might steal that for a follow up video at some point, thanks for sharing!
@asdfg_qwert
@asdfg_qwert 28 күн бұрын
git rebase -i
@philomatics
@philomatics 28 күн бұрын
Thanks for the suggestion! Video on rebasing is in the works!
@Excalibaard
@Excalibaard 29 күн бұрын
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 28 күн бұрын
Ah damn you're absolutely right! Should've filmed my own instead of using stock footage. Video ruined.
Git MERGE vs REBASE: The Definitive Guide
9:39
The Modern Coder
Рет қаралды 80 М.
tree-sitter explained
15:00
TJ DeVries
Рет қаралды 71 М.
WHY IS A CAR MORE EXPENSIVE THAN A GIRL?
00:37
Levsob
Рет қаралды 20 МЛН
TRY NOT TO LAUGH 😂
00:56
Feinxy
Рет қаралды 10 МЛН
Tmux has forever changed the way I write code.
13:30
Dreams of Code
Рет қаралды 907 М.
git rebase - Why, When & How to fix conflicts
9:45
Philomatics
Рет қаралды 17 М.
MUST KNOW bashrc customizations to boost productivity in Linux
13:38
7 Amazing CLI Tools You Need To Try
18:10
Josean Martinez
Рет қаралды 219 М.
Premature Optimization
12:39
CodeAesthetic
Рет қаралды 760 М.
Why Does Scrum Make Programmers HATE Coding?
16:14
Thriving Technologist
Рет қаралды 490 М.
`const` was a mistake
31:50
Theo - t3․gg
Рет қаралды 104 М.
Testcontainers have forever changed the way I write tests
12:11
Dreams of Code
Рет қаралды 108 М.
So You Think You Know Git - FOSDEM 2024
47:00
GitButler
Рет қаралды 984 М.
How To Unlock Your iphone With Your Voice
0:34
요루퐁 yorupong
Рет қаралды 21 МЛН
МОЩНЕЕ ТВОЕГО ПК - iPad Pro M4 (feat. Brickspacer)
28:01
ЗЕ МАККЕРС
Рет қаралды 67 М.
Main filter..
0:15
CikoYt
Рет қаралды 3,4 МЛН
keren sih #iphone #apple
0:16
Muhammad Arsyad
Рет қаралды 1,4 МЛН
WWDC 2024 Recap: Is Apple Intelligence Legit?
18:23
Marques Brownlee
Рет қаралды 5 МЛН
ПОКУПКА ТЕЛЕФОНА С АВИТО?🤭
1:00
Корнеич
Рет қаралды 832 М.