GIT questions

Status
Not open for further replies.

Nexus6

Ars Tribunus Militum
2,193
Hi all,
admin/dev here; just started playing with git, at this point i mostly always used a folder structure of scripts and VS projects. which has worked fine. but, want to start using git to eventually share projects with others. (have maybe 40 VS projects and maybe 100 scripts or so).

i have VS 2013, and started git with the windows GUI sourcetree. trying to wrap my head on the workflow/pattern for git.

i created a directory "git_repos" and inside that i created a folder "test1" which has a .git folder. seems like, the "test1 folder is the working directory work all the "work" is done. then you "stage" is which seems to be a virtual option, and then it gets commited.

so it seems once i have a finshed "project/script" i copy it out of the "repo" structure and "publish" it. seem right so far? what about VS integration? a saw that VS does have GIT extensions, but they seem to be from team viewer?

anyone have thoughts or want to elaborate?


-Nexus6
 

Blacken00100

Ars Legatus Legionis
10,130
Subscriptor
Nothing leaves the repo. You're missing a fundamental somewhere and I'm not sure the exact step so I can't be a ton more specific - I would suggest reading the git (no, not GIT, just like it's not ARS) tutorial and see if that makes things a little clearer.

As for Visual Studio integration - don't, until you are comfortable with using git from a shell. Knowing how git works is largely not optional to using git.
 

ShuggyCoUk

Ars Legatus Legionis
10,387
Subscriptor++
Knowing how git works is largely not optional to using git.

++ to this. Using a gui that tries to hide anything until you know what it is hiding from you is actively harmful to learning to use git.

The simplest way to start using git is to
Code:
git init
in a directory. Hey presto *everything[1]* in that dir is managed by git unless told otherwise. A .git folder will be created in the root that you can initially (and potentially for ever) consider an opaque black box that you just want to make sure is backed up to some remote server somewhere to keep your history safe.

After that start using
Code:
git commit -a .
for really simplistic "I want to save the current state of the directory as a representation of a particular state of the system" and then go on from there with the tutorials. You could perfectly happily use that approach and still get useful value out of it forever, you will likely want to see about branching/tagging/reverting changes and how to use the staging area (called the index) since they all enable more powerful uses.

Note that several of the names for things in the system are, frankly, horrid[2] so your really should follow the tutorial.

1. Technically a few things are excluded by default, you should go and get the standard .gitignore straight away.
2. name something wrong and release it to the world and expect the name to stick, I find it amusing that this 'index' is the third name given to it and it still sucks as being in anyway self explanatory.
 
[url=http:/civis/viewtopic.php?p=28127979#p28127979:1qpghrfr said:
Blacken00100[/url]":1qpghrfr]Knowing how git works is largely not optional to using git.

Yes, you can really save yourself a headache later down the road. As one of the many people who started using GIT with the mindset of "just hack it until it works" or "get it to work with some GUI," I ended up shooting both of my feet.
 

Nexus6

Ars Tribunus Militum
2,193
yea, it seems none of the GUIs work the same or in some cases make it any easier to learn. the GUI for VS was even worse.
guess, I will start working thru the git tuts with some example projects instead of the GUIs. still trying to wrap my head
arround the workflow, part.

so if i have a project, say script1 and it has its own folder already, i just git init in its folder and its added to git? eg, it
creates the .git etc?

and staged vs unstaged, i am assuming staged is when your done with a file and its waiting to be commited?
if i wanted to start sharing these projects i would just spin up linux box and put git on it? (have a git_repo root folder?)
 

tuffy

Ars Scholae Palatinae
972
[url=http:/civis/viewtopic.php?p=28137393#p28137393:1xbtt8re said:
Nexus6[/url]":1xbtt8re]and staged vs unstaged, i am assuming staged is when your done with a file and its waiting to be commited?
Staging is how you prep a file to be committed, and can be done over and over as needed. Like if you're working on file.c and get a bunch of new code working properly, you can stage that file and continue working. Then if you screw it up later on, you can revert to the staged state and try again. Or if you get even more code working properly, you can stage those changes also. Then when all your changes are finally ready, you can commit that staged state into an actual revision with a log message, commit ID and so on.
 

dlp

Ars Tribunus Militum
2,220
[url=http:/civis/viewtopic.php?p=28139331#p28139331:2wfa5s82 said:
tuffy[/url]":2wfa5s82]
[url=http:/civis/viewtopic.php?p=28137393#p28137393:2wfa5s82 said:
Nexus6[/url]":2wfa5s82]and staged vs unstaged, i am assuming staged is when your done with a file and its waiting to be commited?
Staging is how you prep a file to be committed, and can be done over and over as needed. Like if you're working on file.c and get a bunch of new code working properly, you can stage that file and continue working. Then if you screw it up later on, you can revert to the staged state and try again. Or if you get even more code working properly, you can stage those changes also. Then when all your changes are finally ready, you can commit that staged state into an actual revision with a log message, commit ID and so on.
What's the point of constantly staging? CAn you diff between last stage and current state? I typically stage at the time of commit, but commit lots of little changes.
 

chalex

Ars Legatus Legionis
11,918
Subscriptor++
I usually just "git commit -a", but then again, I'm a sysadmin and rarely make big multi-file multi-line changes. Here are some other people's opinions: http://programmers.stackexchange.com/qu ... ss-staging

I found this book to be very helpful in explaining why you may want to use git a certain way: http://www-cs-students.stanford.edu/~blynn/gitmagic/
 

tuffy

Ars Scholae Palatinae
972
[url=http:/civis/viewtopic.php?p=28142933#p28142933:3uarvb1f said:
dlp[/url]":3uarvb1f]What's the point of constantly staging? CAn you diff between last stage and current state? I typically stage at the time of commit, but commit lots of little changes.
"git diff"'s default behavior is to display everything that hasn't been staged, actually. I find lots of stagings is a good way to work toward one big logical change. Like I might stage a file after fixing function "X", then again after fixing function "Y", and again after fixing function "Z" before finally committing: "fixed the --foo option". And if I happen to screw it up between steps, it's easy to backup to the last staged change.
 
The staging area is essentially a commit that you are in the process of creating. You can add to it, remove from it, diff between it and other commits, etc. And since commits reference content by hash in the .git/object container, that means that adding a change to the stage is when it gets copied into .git/objects and hashed. Actually committing is a cheap operation after that.

A simple git workflow doesn't need to think about staging at all; You just stage and commit everything at once. But the stage is nice for projects where the commits are themselves 'products' that get submitted, reviewed, and applied independently, such as open source projects where everything takes place on a mailing list.
 

MilleniX

Ars Tribunus Angusticlavius
8,139
Subscriptor++
if i wanted to start sharing these projects i would just spin up linux box and put git on it? (have a git_repo root folder?)
You can do this, but it's sub-optimal for anything involving more than one or maybe two people. In particular, getting file ownership and group permissions set right and kept right is tough. It's much preferable to install and use an actual Git repository hosting system, like (in rough order of increasing complexity) Gitolite, Gerrit, Gitlab, or Gitorious.
 

dredphul

Ars Tribunus Angusticlavius
6,342
Subscriptor++
[url=http:/civis/viewtopic.php?p=28143647#p28143647:3gurtwjh said:
chalex[/url]":3gurtwjh]I usually just "git commit -a", but then again, I'm a sysadmin and rarely make big multi-file multi-line changes. Here are some other people's opinions: http://programmers.stackexchange.com/qu ... ss-staging

I found this book to be very helpful in explaining why you may want to use git a certain way: http://www-cs-students.stanford.edu/~blynn/gitmagic/

That's bad as you can get crap you don't want added to the commit.

A dev created a history less branch somehow by doing something like 'git commit -a' (I still don't understand how he created it).

A crapton of binaries that shouldn't be under source control and you can't get rid of them w/o filtering history.
 

ShuggyCoUk

Ars Legatus Legionis
10,387
Subscriptor++
[url=http:/civis/viewtopic.php?p=28173763#p28173763:1a7pamum said:
chalex[/url]":1a7pamum]
That's bad as you can get crap you don't want added to the commit.
Well, I always do a "git status" and "git diff" before a "git commit -a" so I know what I'm committing.

++ this is a really good idea whatever the VCS
 
Status
Not open for further replies.