Author Topic: The Power of Git  (Read 1016 times)

Offline Ryex

  • Arctic Bird of Programming
  • Global Moderator
  • Chaos Ultimate
  • ****
  • Posts: 5131
  • LV: 197
  • Gender: Male
  • Wants to write a compiler for fun
    • View Profile
The Power of Git
« on: August 28, 2015, 02:49:54 AM »
git as some of you may know is a DVCS (Distributed Version Control system).

basically that means it can track the changes in files and organize them in a history with out the need of a central server (otherwise it would be a VCS).

what you may NOT know that that git is very different form most VCS's not JUST because it;'s distributed. it also doesn't ACTUALLY track the changes in files per-say. It tracks the changes in data.

"Semantics!" I hear you shout. and I suppose you have a point. For most use cases there is no effective difference. if all your doing is stacking one commit on top of another you'll never notice that git is tracking data not files. Heck, simple merges wont even reveal the difference.

But lest try something. say you have a folder hierarchy.

Code: [Select]
source/
    data/
        file1.txt
        file2.txt
    main/
        prog.rb

and lets say you want to change the name of the top folder to src

Code: [Select]
src/
    data/
        file1.txt
        file2.txt
    main/
        prog.rb

if you make this chagne and then try to commit with a VCS live subversion subversion sees 3 deleted files / 3 deleted folders and 3 new files / 3 new folders. you logs looks like this
Code: [Select]
delete source/
delete source/data
delete source/data/file1.txt
delete source/data/file2.txt
delete source/main
delete source/main/prog.rb
create src/
create src/data
create src/data/file1.txt
create src/data/file2.txt
create src/main
create src/main/prog.rb

but git sees 3 blobs of data with different names so it's log looks like this

Code: [Select]
rename source/data/file1.txt -> src/data/file1.txt
rename source/data/file2.txt -> src/data/file2.txt
rename source/main/prog.rb -> src/main/prog.rb

now svn isn't completely hopeless. SVN can be made aware of renames too. IF you use svn's rename command instead of going through your OS's normal facilities. the difference is that git can detect that rename and svn must be made explicitly aware of it

now I know that seems rather minor but the implications are huge. consider this case:

with the same hierarchy as above what if you had a branch of code working on a feature using the old folder structure. and another contribute makes the commit that renames these three files?
unless your VCS is explicitly aware of the rename how is that merge going to be clean? what if there is a series or renames and the file your working on in your branch isn't even remotely in the same place or using the same name? what if in addition to all that there have been changes (non conflicting changes normal circumstances) to this file? if you attempt to merge your branch  the majority of VCS's wont have a clue what just happened and you'll have to resolve this conflict manually.
git however handles this situation just fine.

as proof I just did this exact thing (abet much more complex) with ARC's source. I changed the naming pattern of a folder, it's sub folders, and it's files to go from CamalCase to lower_case_underscores. some 210 files were affected. meanwhile I had made significant edits to some of those files in another branch. the two branches merged flawlessly without any need for manual conflict resolving.
« Last Edit: August 28, 2015, 02:50:55 AM by Ryex »
I no longer keep up with posts in the forum very well. If you have a question or comment, about my work, or in general I welcome PM's. if you make a post in one of my threads and I don't reply with in a day or two feel free to PM me and point it out to me.

DropBox, the best free file syncing service there is.
(click to show/hide)

Offline Blizzard

  • This sexy
  • Administrator
  • has over 9000 posts
  • *****
  • Posts: 19905
  • LV: 642
  • Gender: Male
  • Magic midgets.
    • View Profile
    • You're already on it. (-_-')
Re: The Power of Git
« Reply #1 on: August 28, 2015, 08:55:16 AM »
Uhm, yes, of course you are going to use "rename" in SVN. It's a basic functionality.

I'm sorry, I know you love git and all, but being forced to work sometimes with it now, the only thing I can say is that git has some very advanced features that I rarely use and the simplest things are made so goddamn overcomplicated that I rage every single time I have to work with it. Just the other day I realized git doesn't support empty directories. Goddamn empty directories. Or that for some reason pushing stopped working when I committed something without pushing it immediately. (It kept telling me that it was already pushed even though it wasn't.) Granted, this is may be a bug in the git client. But something used this often shouldn't really shouldn't be that difficult to implement. And NO externals? What the fuck? I excepted that I would get an upgrade to SVN, not a downgrade. And I'm not even gonna start with default-ignores. There was no .gitignore file ANYWHERE in my repo, yet the client would not recognize the directory "bin" and I had to add it go to the ignored directories EVEN THOUGH THERE ARE NO DIRECTORIES YET DEFINED AS IGNORED. Granted again, this my be the client's fault again. But for something called "the best visual git client available", it has an awful lot of problems.

[/rant]

I use Sourcetree, BTW. Using command line for handling loads of data is just plain stupid. Unless you can keep track of 30 files in your head at times, distributed over 3-4 libraries, you're gonna get lost and you're not gonna commit things properly.

EDIT: Don't get me wrong, it's fantastic that it will rename 200 folders automatically without having to use a special rename command all the time. But if all this data is like 10 MB big, it's really not much of a waste of space if you just SVN delete and re-add it. Look at it from this perspective: Theoretical optimum vs. practical situation. Git may lean more towards the first while SVN leans towards the latter and while git is way more advanced than SVN, I have yet to see a real-life problem in versioning that git will solve better than SVN in a meaningful way. So far all I have come across are limitations and complications. "What, git does NOT support this? But it's supposed to be BETTER than SVN. Why is such a simple and useful thing not supported?" is what always comes to my mind.
« Last Edit: August 28, 2015, 09:19:00 AM by Blizzard »
Check out Daygames and our games:

King of Booze      King of Booze: Never Ever      Pet Bots
Drinking Game for Android      Never have I ever for Android      Pet Bots for Android
Drinking Game for iOS      Never have I ever for iOS      Pet Bots for iOS
Drinking Game on Steam


Quote from: winkio
I do not speak to bricks, either as individuals or in wall form.

Quote from: Barney Stinson
When I get sad, I stop being sad and be awesome instead. True story.

Offline Ryex

  • Arctic Bird of Programming
  • Global Moderator
  • Chaos Ultimate
  • ****
  • Posts: 5131
  • LV: 197
  • Gender: Male
  • Wants to write a compiler for fun
    • View Profile
Re: The Power of Git
« Reply #2 on: August 28, 2015, 11:33:43 AM »
I think you have a warped perception of git blizz. It certainly isn't a silver bullet but it dose do a lot of things literally impossible with other clients.

On empty folders: I'll agree this is a limitation in some workflows. The accepted practice is to put an empty file named empty in the folder. But when you think about it it makes prefict sense that empty folders arn't supported. After all it tracks data not files. Not that should prevent an empty data object from being used to hold the folder's place.

On externals: it does actually have exterals. They are called submodules and are actually capable of more than sun externals, of course like git this means more complexity but they are still simple to work with. You just run 'git submodule update' and then add and commit. Your repo will record the commit of the current module's state and your good to go. This allows a tag in the main repo to use one state from the submodule repo.

There are a lot of magic things you can do too like rewrite history ect.

But in a general git workflow you only stage commit push and pull. Did you know you can make a bunch of edits to a file, save them all, then only stage part of them for committing at a time?  That's powerful stuff.

I know it seems like I'm a big fan of git but really it's just a tool. Thing is that I keep finding out it can do things that greatly simplify my workflow or save my ass ect.

As for sourcetree Atlassian tries real hard to sell that thing but it really is pretty buggy. Github for Windows is ostensibly better even if it's more limited. The truth however is that a GUI does not exist that can use git's full power. Frankly the best I'v ever found were plugins for Sublime Text or Github's atom. Those worked because they didn't try to obfuscate what git was doing you sill basically had git's cmd interface but didn't have to type.
frankly if your working it git it's just best to use the cmd sometimes. I know that is unattractive to a good number of devs out there (personally I question the competence of a programmer who wants to avoid the command line,  but that's just an opinion). Git was developed to fit the needs of large distributed teams and designed to allows workflows for that context. In some small localised team setups the power of git is unnessacery. If all you need to do is get from point a to point b,  you don't need a supercar with spy gadgets. But that doesn't mean it's a bad car, just that it's a lot more car than you need. But if you explore and find that some of those spy gadgets are useful in your everyday life would that not be a good thing?

tl:dr complaining that a super tool is harder to use is silly.

Edit; on your ignored folder problem. I think sourcetree respects global ignore files and may have even instead one. Also file ignore patterns may be set in a config file inside the .git folder of the repo. Check your ignores,  the answer here has instructions to find global and local ignores in sourcetree https://answers.atlassian.com/questions/158997/how-to-track-an-ignored-file
« Last Edit: August 28, 2015, 11:56:49 AM by Ryex »
I no longer keep up with posts in the forum very well. If you have a question or comment, about my work, or in general I welcome PM's. if you make a post in one of my threads and I don't reply with in a day or two feel free to PM me and point it out to me.

DropBox, the best free file syncing service there is.
(click to show/hide)

Offline Blizzard

  • This sexy
  • Administrator
  • has over 9000 posts
  • *****
  • Posts: 19905
  • LV: 642
  • Gender: Male
  • Magic midgets.
    • View Profile
    • You're already on it. (-_-')
Re: The Power of Git
« Reply #3 on: August 28, 2015, 07:11:12 PM »
I know it has submodules, but they aren't the same. Submodules are inferior. Submodules are added to the working copy as a copy and don't refer to the actual remote repo. I've looked it up and I was surprised that after so many years that SVN exists, git still doesn't support something like this.

My view of git is what everybody else tells me:
Quote from: every git fanboy ever
Oh, git is sooooooo much better than SVN. SVN is a babytoy compared to git.
And now that I have to work with it, I completely disagree. It's different, not better.

You can rewrite the logs in SVN as well. You just have to turn it on on the repo.

Alright, good to know that I'm not imagining things and other people have problems with Sourcetree as well. ._.

IMO command line is fantastic for automation. But using it constantly just doesn't work for me. A simple example: What's better? Having to open a cmd window in a directory to type git add "this is a long filename.txt" or SVN by default already assuming that you want to commit your changes to the file without having to switch the file from unstaging manually to staging? The latter is much faster, because it doesn't require additional actions.

I think that a good tool can be simple to use. Sure, some advanced features are always more complicated, but that's natural. But simple (and often used) functionality should be accessible easily and simple to use. Being a "super" tool doesn't excuse a needlessly cumbersome workflow. And obviously it's possible to make it better since other versioning systems have already done it better.

IDK about the ignore directory. There is no .gitignore file anywhere, but I haven't checked the .git file as I assume that .gitignore is used for ignores, not .git since it's named, well, .gitignore. >.<
« Last Edit: August 28, 2015, 07:19:10 PM by Blizzard »
Check out Daygames and our games:

King of Booze      King of Booze: Never Ever      Pet Bots
Drinking Game for Android      Never have I ever for Android      Pet Bots for Android
Drinking Game for iOS      Never have I ever for iOS      Pet Bots for iOS
Drinking Game on Steam


Quote from: winkio
I do not speak to bricks, either as individuals or in wall form.

Quote from: Barney Stinson
When I get sad, I stop being sad and be awesome instead. True story.

Offline Ryex

  • Arctic Bird of Programming
  • Global Moderator
  • Chaos Ultimate
  • ****
  • Posts: 5131
  • LV: 197
  • Gender: Male
  • Wants to write a compiler for fun
    • View Profile
Re: The Power of Git
« Reply #4 on: August 28, 2015, 11:01:15 PM »
Supermodels absolutely DO refer to their remote repository. They are a full git repository and the repository they are added to records their URI and the commit hash to use from that repository https://git-scm.com/book/en/v2/Git-Tools-Submodules. Because they are a full repository if you want to update the submodule to the latest version in it remote redo you open the sub-module as it's own repository and run a pull. if you want the main repository to records the new submodule state you update your submodule and then go back to the main repo, stage, and commit. if you make changes to the code in the sub module treat it like it's own repository, stage, commit, and push from the submodule directory and you'll only affect the submodule.

also typing 'git add Long_file_name_here.ext' is almost never done. the vase majority of the time you just type 'git add --all' or 'git add .' if you don't want to add any un-tracked files. also, this is what tab completion is for if your on windows look up clink.

.git is a folder that hold all the information about the repository. It can hold repository specific git configuration which includes ignore patterns. the .gitignore it just the third place to specify ignored file patterns not the primary.

I've never once found git cumbersome, I'v certainly been clueless how to do something but no matter how complicated your task is it can usually be done in one to two commands. even committing changes can be done in one command. 'git commit -a' will add all changed indexed files including deleted once and commit. if you need to get more complex use 'git commit -i' for interactive mode or 'git commit -p' for patch mode. you can even skip the 'add' staging area and just pass a list of file names to the commit command.

I don't mean this as a disparaging, but I'm pretty sure you just haven't learned how to use git yet. I say this because your comments appear to assume things about how git works that arn't true. I know that time is hard to come by sometimes  if if you have half an hour for professional improvement checkout Atlassian's tutorials https://es.atlassian.com/git/tutorials. They probably do a better job than most getting people who are used to other VCS's to understand git. It really is a completely different beast than CVS, SVN, or even Hg. Of particular intrest is probably the section on workflow, That seems to be your biggest hangup with being forced to use git.

As for other systems having done it better I really do beg to differ, Hg is PAINFULL to work with. it tires to do everything git can while still being SVN and it fails horribly. bzr is... will bizarre and stupid slow.
« Last Edit: August 28, 2015, 11:22:22 PM by Ryex »
I no longer keep up with posts in the forum very well. If you have a question or comment, about my work, or in general I welcome PM's. if you make a post in one of my threads and I don't reply with in a day or two feel free to PM me and point it out to me.

DropBox, the best free file syncing service there is.
(click to show/hide)

Offline Blizzard

  • This sexy
  • Administrator
  • has over 9000 posts
  • *****
  • Posts: 19905
  • LV: 642
  • Gender: Male
  • Magic midgets.
    • View Profile
    • You're already on it. (-_-')
Re: The Power of Git
« Reply #5 on: August 29, 2015, 08:51:58 AM »
I just looked it up and yes, they do seem to keep pointing to the remote repo. Maybe I misunderstood something I read online. Either way, this is a good article about their differences: http://alexking.org/blog/2012/03/05/git-submodules-vs-svn-externals One of the problems we encountered is definitely that you can't use deep URLs. And we kinda need that.
I remember reading that article you posted a while ago. I got through two screens and then looked at the right and saw how enormous it was and I was like "Why is something so simple explained in a text as big as a novel? Even if it's in command line, this is ridiculous." This is why my view of git is that it's needlessly complicated.

I know that "git add Long_file_name_here.txt" is rarely done, but IMO it's dumb that you even have to do "git add --all". Tab completions is fine and all, but adding 20 files like that can easily waste a minute. A minute you don't have to waste at all in SVN, because files are added by default. The only good flipside in git is IMO that you don't have to add or delete files to the repo explicitly like in SVN. But you are going to edit files far more often than you're going to add or delete them.

Alright, I'll keep that with the .git file in mind. Good to know.

Just adding ignored files is cumbersome. In SVN it's just 2 clicks. Adding an external is just a few clicks and typing in the URL and then hitting a recursive update. In that article I linked above you can see how long it takes to get a submodule running on git. Whenever I use git, I have a feeling that it's slowing me down and that I usually do the same thing in SVN faster.

I took a quick look at the list of tutorials. I know how to use the basic functionality in git, but it still doesn't feel right. I think I'm gonna try TortoiseGit. Maybe it will smooth things out.

I never said anything about Hg, lol! Seriously, why anybody would use it is beyond me. You said it well. It's like it's trying to be git, but in a bad way.
Check out Daygames and our games:

King of Booze      King of Booze: Never Ever      Pet Bots
Drinking Game for Android      Never have I ever for Android      Pet Bots for Android
Drinking Game for iOS      Never have I ever for iOS      Pet Bots for iOS
Drinking Game on Steam


Quote from: winkio
I do not speak to bricks, either as individuals or in wall form.

Quote from: Barney Stinson
When I get sad, I stop being sad and be awesome instead. True story.

Offline Ryex

  • Arctic Bird of Programming
  • Global Moderator
  • Chaos Ultimate
  • ****
  • Posts: 5131
  • LV: 197
  • Gender: Male
  • Wants to write a compiler for fun
    • View Profile
Re: The Power of Git
« Reply #6 on: August 29, 2015, 09:34:05 AM »
again you DONT have to do 'git add --all' first. you could just jump strait to the commit step and pass either the -a option or the file names to commit.

ok, google foo is failing me. what is a deep URL?

You completely right that git is far more complex that svn and, again, if you don't need all the fancy tools it offers then it might seem needlessly complex.

but just consider for a moment that git comes with a whole suite of tools that are really useful if you ever have need of them.

For example 'git bisect' lets you do a binary search to hunt down which commit introduced a bug

https://git-scm.com/book/en/v2/Git-Tools-Debugging-with-Git#Binary-Search

git maintains a reflog which is different than the branch commit log and yet the same. the reflog lets you go back in time with the actions you have done on the repository. it lets you undo a merge or rebase or anything really.

git has a reference manual the size of a text book because it can do a textbook's worth of things. but if all you need is a single branch single server workflow that can seem really overwhelming. but at the same time like any good tool if you really know it it can do incredible things for you, even in the simple cases.

TortoiseGit probably is one of the better gui interfaces for git, but personally I still feel like it's flawed. I can commit a hell of a lot faster through a command line, but then I'm used to the command line.
I no longer keep up with posts in the forum very well. If you have a question or comment, about my work, or in general I welcome PM's. if you make a post in one of my threads and I don't reply with in a day or two feel free to PM me and point it out to me.

DropBox, the best free file syncing service there is.
(click to show/hide)

Offline Blizzard

  • This sexy
  • Administrator
  • has over 9000 posts
  • *****
  • Posts: 19905
  • LV: 642
  • Gender: Male
  • Magic midgets.
    • View Profile
    • You're already on it. (-_-')
Re: The Power of Git
« Reply #7 on: August 29, 2015, 02:00:18 PM »
It's simple. With submodules you HAVE TO checkout the entire submodule repo. SVN externals allow you to checkout only a certain directory. e.g. in AprilUI we have a util directory and in there we have Texture Packer project setups that we use. In our CAGE SDK repo there is no need to checkout the entire AprilUI repo. All we need there is that Texture Packer directory.

Undoing merges is supported in SVN. It's done by "reverse-merging".

Yeah, I've seen the git manual. So much text. #_#

If TortoiseGit is better than Sourcetree, then I'll take it. I'll install it at work next week.
« Last Edit: August 29, 2015, 02:01:48 PM by Blizzard »
Check out Daygames and our games:

King of Booze      King of Booze: Never Ever      Pet Bots
Drinking Game for Android      Never have I ever for Android      Pet Bots for Android
Drinking Game for iOS      Never have I ever for iOS      Pet Bots for iOS
Drinking Game on Steam


Quote from: winkio
I do not speak to bricks, either as individuals or in wall form.

Quote from: Barney Stinson
When I get sad, I stop being sad and be awesome instead. True story.

Offline Ryex

  • Arctic Bird of Programming
  • Global Moderator
  • Chaos Ultimate
  • ****
  • Posts: 5131
  • LV: 197
  • Gender: Male
  • Wants to write a compiler for fun
    • View Profile
Re: The Power of Git
« Reply #8 on: August 29, 2015, 08:10:10 PM »
AH!, what your looking for is known as shallow clones and sparse checkouts. shallow clones let you clone a repo and only retrieve part of the history, sparse checkouts let you only checkout part of the repository. It will end up significantly more complicated but it CAN be done.

the two actions can be done entirely separate form eachother so you can shallow clone your sub-module if you want and or sparse checkout if you want.

for a sparse checkout read this http://git-scm.com/docs/git-read-tree the sparse checkout section is further down
just remember to turn on support for sparse checkouts in your submodule repo config
Code: [Select]
git config core.sparseCheckout true
basically make a file that looks like repo/.../<my-module>/info/sparse-checkout and tell it what files you want in there cd into your sub module and run 'git read-tree'

if your freshly cloning this might be useful to you
https://gist.github.com/kouk/3ba77edce12e95c1f779#file-shallow-submodule-add

Your right that this is far more complicated, but it CAN be done.

It also has a lot more power than SVN's strait sub directory checkout. as you can literally populate your working directory with any file in the repo
I no longer keep up with posts in the forum very well. If you have a question or comment, about my work, or in general I welcome PM's. if you make a post in one of my threads and I don't reply with in a day or two feel free to PM me and point it out to me.

DropBox, the best free file syncing service there is.
(click to show/hide)

Offline Blizzard

  • This sexy
  • Administrator
  • has over 9000 posts
  • *****
  • Posts: 19905
  • LV: 642
  • Gender: Male
  • Magic midgets.
    • View Profile
    • You're already on it. (-_-')
Re: The Power of Git
« Reply #9 on: August 29, 2015, 11:47:09 PM »
I see. Alright, I'll check it out when I have time. I'll have to set up ARC with this.

EDIT: I've tried TortoiseGit for about half a minute and I already love it more than I ever could love Sourcetree. *uninstalls Sourcetree*
« Last Edit: August 31, 2015, 07:48:19 AM by Blizzard »
Check out Daygames and our games:

King of Booze      King of Booze: Never Ever      Pet Bots
Drinking Game for Android      Never have I ever for Android      Pet Bots for Android
Drinking Game for iOS      Never have I ever for iOS      Pet Bots for iOS
Drinking Game on Steam


Quote from: winkio
I do not speak to bricks, either as individuals or in wall form.

Quote from: Barney Stinson
When I get sad, I stop being sad and be awesome instead. True story.