Proper team etiquette will assist your team to achieve seamless collaboration and productivity. These rules are often gained with experience as mos...
For further actions, you may consider blocking this person and/or reporting abuse
Just wondering why all the
git
commands in the code blocks start with a capital G, yet thetouch
command in them, and thegit
commands in the Handle Large Files section start with lower case...?I write my drafts in a google doc and didn't realize it capitalized those
Git
commands. I updated it! Thank you for pointing that out!Great article, I'll be sharing with my developers! One thing that stuck out though is that there are different philosophies out there for
origin/master
and devs may run into repos where that branch is what is deployed rather than ready to deploy.That is a great point Bryan! I edited my post to include both possibilities. Thank you for the suggestion :)
Love this article and plan to share it with others, but the token naming part has me stuck. I've actually had several issues with other non-git software that interacts with branches that have / in their name. So we name things feature-, bug-, etc instead of feature/, bug/. Jenkins for instance seems to break on the / naming convention and I know I've run into problems in other software too.
That is a really good point Anthony! I've updated this article to suggest any of those name conventions (using
/
or-
) and added a note for the ones that are using Jenkins or other third-party tools in their CI/CD implementations. I'm glad you brought this up as I haven't encountered this issue in the past. Mostly because my team uses Gitlab CI and thankfully/
do not affect our pipelines.I'm glad you enjoyed this article and thanks again for the suggestion!
Thanks for putting it together.
git fetch --prune --all
is a very useful command and it is also possible to automate this process withgit config remote.origin.prune true
It deletes branches when you do a git pull/fetch if they were deleted on the remote.EDIT: Actually I misunderstood the prune command a bit 😅 The prune option will only delete remotely deleted references in your working tree under remotes/* . Your local branches will be kept and you have to still delete them manually with git branch -d.
Or simply
git config --global fetch.prune true
if you want this in all your repos.Nice! I haven't you used that configuration before. I'm excited to try it out :)
Nice article summarizing some good practices!
Also wanted to add there's a newer way to delete a remote branch.
This was added I think because it could be easier to understand and remember.
I'll note though that, at least in my experience, it doesn't let you tab-complete the branch name if you delete the local branch first. But it will if you delete the remote branch before deleting the local one.
However, if you do delete the local branch first, using the other method you mentioned will still let you tab-complete the remote branch name.
Not sure why tab completion doesn't work with the new way of deleting remote branches, but oh well... 🤷♂️
That is a great point, the branch deleting command you added is definitely easier to understand and remember. I added your suggestion to the post, thank you for bringing it up!
In regards to the issues you are having with tab-completing a branch name, I’m not sure why bash git completion does not recognize those two commands as the same, I will look into it and let you know if I find out why this is happening.
Side note, starting on Git v2.8.0 you can use
git push
with the-d
option as an alias from—delete
, in case you like this shortcut better.Thank you again for reading and providing suggestions! :)
Oh neat! That'll be even nicer. :) Thanks!
Another great article Milu! I have a question and a suggestion:
Question: What is
--list
in this line of codegit branch --list “feature/*”
? It looks like it might be the name of the branch. I went back to your earlier article Git Explained: The Basics and didn't notice a naming technique for creating new branches. Whereas, this Atlassian article on branches doesn't use any hyphens to prepend a branch name.Suggestion: I noticed your list of previous posts at the bottom, would you mind being redundant and adding them to the top as well? I'm saving these and having a quick reference as to sequence, above the fold, would be very handy.
Hi Dani!
The command
git branch
orgit branch —list
shows you all the branches you are keeping up with locally. You also have the option to give this command an argument in order to only see a group of branches. For instance, if I followed the token advice mentioned in this article, I should have some branches that start withfeature/name-of-branch
and other that start withbug/
. If I want to only list all the branches that add a feature and ignore all the bug branches, I can give it an argument that asks for all the branches that start withfeature/*
(the asterisk is like a wild card).I hope this explanation helps clarify that command.
Also, thank you for the suggestion, I didn’t know this before you mentioned it but you can do a “series” of posts and they all link to each other at the top of the page. So I took care of that :) Thank you!
Right on! Thanks for the detailed explanation of
git branch
and for making this into a series :)Love that you pulled all these great practices together. Thanks for the reminders and new info!
Thank you for the kind words Zachery! Glad you enjoyed this post :)
Very informative and well written!
Thank you Vishnu!
Thank you for this very informative article on Git. Appreciate it! :)
Thank you for the kind words Hari! I'm glad you found it helpful :)
Really nicely done, thanks for this. The illustrations are beautiful!
Thank you Josh! I really appreciate the encouragement and kind words :)
Thanks for this. Learned a few tricks I didn't know.
That is fantastic! I'm glad this post was helpful to you Shane! Thank you for reading.
I like the pictures Milu, where did you create? tool/software?
Hi Sandeep, my illustrations are done using an iPad and an app called Paper Pro. Glad you like them!
using "/" as part of the branch names may look cool, but will definitely causes trouble on CI / CD pipelines.
I suppose that depends on your CI/CD tool. At my work we use GitLab CI and it works well, in fact one of the teams has the tool configured to run certain jobs based on whether the branch is a feature branch or pre-release.
Same here Vincent, my team uses GitLab CI so I haven't experienced any issues using
/
in our branch name conventions.However, that is a good thing to note as other teams have different implementations. I added a note for it Gerardo. Thanks for the suggestion!
When the application is containerised, having this convention will make it not feasible, for example, to have images tagged by its code branch. It's not a showstopper, but the kind of small nuisance that takes time.
That is such a great resource! Thank you for sharing, Rob!
Great tips Milu, will be sure to share these with team members and people I know who might be CLI reluctant.
To take Rob's tip one step further, Github has a helpful site to generate a
.gitignore
file for a number of platforms and languages in one step - gitignore.io. They even provide an API of sorts, so you can stay in the command line the whole time!This is such a cool tool Hugo! I'm planning to use it in my projects from now on. I added it to the post so more people learn about it. Thank you so much for sharing :)