Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
nexus6
Sep 2, 2011

If only you could see what I've seen with your eyes
Man, I really wished I worked with someone who understood git, or received any training. I've been reading http://book.git-scm.com/4_rebasing.html and I can't follow those diagrams. I'm also getting confused by the term 'commit' having just come from SVN.:smith:

Adbot
ADBOT LOVES YOU

Mithaldu
Sep 25, 2007

Let's cuddle. :3:
Watch this: http://blip.tv/open-source-developers-conference/git-for-ages-4-and-up-4460524

The first half should educate you plenty. :)

nexus6
Sep 2, 2011

If only you could see what I've seen with your eyes

Mithaldu posted:

Watch this: http://blip.tv/open-source-developers-conference/git-for-ages-4-and-up-4460524

The first half should educate you plenty. :)

Thanks for that, it's really useful!

Edit: After watching that video I had a look at our tree. It appears that the new 'origin' and the origin I was working from are actually identical and refer to the same node, so I don't know why they want branches redone.

The more you know!

nexus6 fucked around with this message at 18:02 on Dec 12, 2011

Fangs404
Dec 20, 2004

I time bomb.
I just setup Mercurial on my VPS. I'm trying to push my main repo, but I'm getting this error:

code:
searching for changes
remote: adding changesets
remote: adding manifests
remote: adding file changes
abort: unexpected response: empty string
[command returned code 255 Mon Dec 12 07:19:00 2011]
I'm pushing from Windows 7 x64 using TortoiseHg 2.2.1 to Ubuntu 10.04 LTS x32 running Mercurial 2.0 (thanks to https://launchpad.net/~mercurial-ppa/+archive/releases).

The repo has the same group/user permissions as the SSH account (recursively set). /tmp contains a hg-unbundle file that's 3.8gb (right at the size of my repo). Anyone know how I can fix this without reuploading the entire repo? If I look at the size of the repo, it's 474mb, but inside the .hg/store directory, I can see there's still a lock on the repo.

[edit]
gently caress it, I just wiped the repo. Gonna try again from scratch.

[edit2]
I was able to fix it. For anyone that encounters this error, I think it's because I was trying to push a larger changeset than Mercurial could handle (whether the limit is memory or something inherent in Mercurial itself, I'm not sure). I fixed this by splitting up my pushes into several 400mb-500mb pushes. These each completed successfully. Does Git do any better with really large repos?

[edit3]
Turns out that wasn't actually the problem either. I made edit2 when I was like 3 pushes in, and I thought that was gonna work. The problem was that I had 1 file that was very large (500mb). Mercurial apparently handles all files as Python strings in memory. My VPS is a Linode 512, so what was happening was that I was running out of memory (physical and swap). I deleted the file, wiped the repo, pushed the entire repo from scratch, and it worked!

The takeaway here is that Mercurial isn't very good at handling large files. I'm sure that if I had a more beastly server with something like 4gb+ RAM, I would've been just fine, but know that Mercurial uses memory proportional to each file size on the receiving machine when pushing a repo.

Fangs404 fucked around with this message at 14:52 on Dec 14, 2011

Golbez
Oct 9, 2002

1 2 3!
If you want to take a shot at me get in line, line
1 2 3!
Baby, I've had all my shots and I'm fine

Plorkyeran posted:

git push origin :branchname to delete a remote branch.

Thanks, by the way, to you and pseudorandom name. This worked. :)

Golbez fucked around with this message at 16:28 on Dec 13, 2011

Pardot
Jul 25, 2001




nexus6 posted:

Man, I really wished I worked with someone who understood git, or received any training. I've been reading http://book.git-scm.com/4_rebasing.html and I can't follow those diagrams. I'm also getting confused by the term 'commit' having just come from SVN.:smith:

Make a dummy repo with like 5 files. Make a bunch of commits changing them, make branches, change them etc, then start playing with the commands and see what the results are. Practice makes perfect.

Golbez
Oct 9, 2002

1 2 3!
If you want to take a shot at me get in line, line
1 2 3!
Baby, I've had all my shots and I'm fine
In git, we have our master/live branch, and a test branch that we throw projects in whenever they need testing. All our projects branch off master, and we merge them into test as needed. Due to some poor decisions a few months ago and possibly a bad merge more recently, test is becoming unusable. When I branch a new branch off master and want to merge it into test, I now have to deal with so many inconsistencies that it's easier to just copy the changed files out of my development branch and copy them manually into the test branch, rather than try merging.

My plan for resolving this is to nuke test and reclone it from master, then merge back in all of our development branches that are currently in testing. My fear, though, is that since test will technically be newer than the development branches (having been cloned off a more recent version of master) that the branches won't want to properly merge in; I've had problems in the past where, before I fully learned how git worked, I wasn't able to merge changes into a branch because it was considered more recent than the development branch, or some weirdness.

So, does this sound like it will work or will it bite me in the rear end?

Edit: Just tested it, looks like it would bite me in the rear end:
pre:
$ git checkout -b testing_this master
Switched to a new branch 'testing_this'

$ git merge --no-commit new_feature
Already up-to-date.
"new_feature" in this case being a branch that split off from master a few weeks ago and has, well, a new feature in it.

What are my options here to shore up the testing branch?

Golbez fucked around with this message at 23:23 on Dec 27, 2011

ColdPie
Jun 9, 2006

Are you sure the commits in the feature branch are not already in master? I think that's what that error message means.

Golbez
Oct 9, 2002

1 2 3!
If you want to take a shot at me get in line, line
1 2 3!
Baby, I've had all my shots and I'm fine

ColdPie posted:

Are you sure the commits in the feature branch are not already in master? I think that's what that error message means.

They're definitely not, no.

What I think it's seeing here is that the feature branch came off master from weeks ago, so now when trying to merge into this new testing branch, it sees, "Oh, this master is more recent than what I branched from! It is therefore up to date and there's nothing I can add."

Edit: Which makes no sense, because I know that when I merge that branch back into master, despite master being newer, it will happily merge the files in. So I have no clue what's going on.

Edit again: Found the problem:
* A feature had been branched off months ago from test instead of master.
* When I merged it into master, I cherrypicked what I wanted in. Unfortunately this still sucked in a bunch of test's history into master.
* So when I branched a new feature off master and tried to merge it into test, a bunch of legacy conflicts appeared.
* Solution was to roll back master to before test infecting it, recommit any changes since then, and rebranch those features off the new master.

Golbez fucked around with this message at 18:13 on Dec 28, 2011

Scaevolus
Apr 16, 2007

Fangs404 posted:

The takeaway here is that Mercurial isn't very good at handling large files. I'm sure that if I had a more beastly server with something like 4gb+ RAM, I would've been just fine, but know that Mercurial uses memory proportional to each file size on the receiving machine when pushing a repo.
You may want to look into hg's Large files extension to handle these things more efficiently.

mobby_6kl
Aug 9, 2009

by Fluffdaddy

Fangs404 posted:

I just setup Mercurial on my VPS. I'm trying to push my main repo, but I'm getting this error:
:words:

That will certainly be useful to know once my projects aren't <10MB of source total, I had no idea Mercurial would have a problem with this. May I ask though how you set up Mercurial to push stuff to your VPS? I have a bunch of repos on my local windows machine, and would like to push them to my host (NFS). It's a basic shared deal, but i have SSH access and used it successfully to connect to the SQL server. I already tried this a few times based on some incomplete information I found, but with no success.

SavageMessiah
Jan 28, 2009

Emotionally drained and spookified

Toilet Rascal

mobby_6kl posted:

That will certainly be useful to know once my projects aren't <10MB of source total, I had no idea Mercurial would have a problem with this.
The problem isn't the size of the repo, it's that he had a 500mb file in there.

mobby_6k1 posted:

May I ask though how you set up Mercurial to push stuff to your VPS? I have a bunch of repos on my local windows machine, and would like to push them to my host (NFS). It's a basic shared deal, but i have SSH access and used it successfully to connect to the SQL server. I already tried this a few times based on some incomplete information I found, but with no success.

Just ssh into your server (I assume you have hg installed there) and run hg init to create a new, empty repo.
Then on your local machine just hg push ssh://you@wherever.net:/path/to/repo. That's all you need to do. I'm assuming the normal hg distribution for windows has ssh support out of the box, we use tortoisehg at work and handle interaction with the master hg server in exactly this way.

EDIT: Oh it looks like you probably can't have hg installed on the server. In that case just hg bundle -a ../repo-name.hg and scp that to the server and push to that. Or zip a clean clone and stick that up there, whichever.

SavageMessiah fucked around with this message at 22:26 on Jan 4, 2012

Rocko Bonaparte
Mar 12, 2002

Every day is Friday!
I have some questions about using git. I am using it for personal projects, which means I'm the only one writing code for it. However, I do sometimes use a different computer. All hell broke loose on me while doing that, although a lot of that I think has to do with Windows volunteering to fix some files in the git source tree.

Help me understand how to more properly use it here. I was doing a pull up front, committing code, and then pushing it back. It's my understanding this is naughty, and I should be using a branch for all this. So is it like this:

1. Declare a branch for the project into which I will be merging from now on as my "trunk."
2. When I get the inkling to screw with my code, declare a branch on my local copy.
3. Muck around with the branch, committing to that branch as I feel like it.
4. Merge that branch into the trunk.

Will that merge go up to the server? Do I push to that branch on the server?

I was also thinking that I have some personal hosting that doesn't get much use. I was thinking I'd set up my repository on it and use SSH. If git is not technically installed on the host machine, can I expect problems? If everything is kosher there, how do I set up the repository there? Can I just copy my local hard disk master repository up on there and expect good things?

ColdPie
Jun 9, 2006

Branches are complicated and generally not worth it for a single developer scenario, in my opinion. Have you read http://progit.org/book/ ? Especially chapters 1, 2, 3, 5, and 6. My suggestion would be to use git-rebase much more than git-merge and git-pull (If you don't know what that means, please keep reading :) ), since linear histories are much easier to understand.

E: About your server, read chapter 4. SSH access might be sufficient. I'm not sure if that requires Git installed on the remote end.

ColdPie fucked around with this message at 16:46 on Jan 14, 2012

Dromio
Oct 16, 2002
Sleeper
My (all windows based) team has started to get used to git and we've got a pretty good convention around branch names. However, every once in a while someone will accidentally push a branch with the something in the wrong case. For example, the original branch was "ticket/3092--FixSomething" and the guy checks it out but then somehow pushes to "Ticket/3092--FixSomething".

So now, whenever I do a git fetch it tells me there's something new:

code:
$ git fetch
From theserver
 * [new branch]      Ticket/3092--FixSomething -> origin/Ticket/3092--FixSomething.  
$ git fetch
From theserver
 * [new branch]      Ticket/3092--FixSomething -> origin/Ticket/3092--FixSomething.  
Over and over again. It makes me worry that if I push origin :Ticket/3092--FixSomething it might get confused and delete the wrong branch.

Any ideas on how to get out of this mess?

Dromio
Oct 16, 2002
Sleeper
I talked with the Dev and he'd already realized his mistake and put his changes into the right branch, so I was able to just push origin :Ticket/3092--FixSomething and all is fine.

But this is the third time it's happened and it's really getting annoying.

Mithaldu
Sep 25, 2007

Let's cuddle. :3:
I have no idea how the hell something like this could happen. Are you using the latest MSysGit?

Dromio
Oct 16, 2002
Sleeper
They've managed to do it with msysgit, smartgit and tortoise.

Mithaldu
Sep 25, 2007

Let's cuddle. :3:

Dromio posted:

They've managed to do it with msysgit, smartgit and tortoise.

Maybe they're using this stickykeys feature that uppercases the start of words, or are typing on a cellphone ...

Dromio
Oct 16, 2002
Sleeper

Mithaldu posted:

Maybe they're using this stickykeys feature that uppercases the start of words, or are typing on a cellphone ...

This might not be too far off really. I do expect he has to use special accessibility tools that might be too vigorous in trying to make sure his text entry is correct-- this particular developer is partially paralyzed. I suppose I should ask him if our naming conventions are difficult with his tools.

ufarn
May 30, 2009
I have a development branch, let's call it dev:

code:
  master
* dev
I checked out to this branch, made some changes, after which I added and committed them. But when I try to push the changes to my GitHub repo, I just get an "Everything is up to date", and nothing is pushed to my GitHub repo.

The changes have definitely been made, and I can see the differences when I check out to the other branch, but the changes aren't getting pushed for some reason. I'd - obviously - like to view my branch on GitHub, but git won't let me.

What's up?

Mithaldu
Sep 25, 2007

Let's cuddle. :3:

ufarn posted:

What's up?
If the branch of your local repo does not exist in the remote already, you need to specify it manually, i.e.:

git push origin dev

ufarn
May 30, 2009

Mithaldu posted:

If the branch of your local repo does not exist in the remote already, you need to specify it manually, i.e.:

git push origin dev
Awesome, thanks a bunch!

Rocko Bonaparte
Mar 12, 2002

Every day is Friday!
Do you need git installed on a remote machine to use git locally with SSH with the remote space? I know the normal thing to do is to do the git administration on the remote machine--particularly the git init that starts the whole mess. But is it really necessary? Could I set up a .git hierarchy in some directory, and then run all the git operations from my client machine? I don't know what operations git is doing over the SSH link.

ToxicFrog
Apr 26, 2008


Rocko Bonaparte posted:

Do you need git installed on a remote machine to use git locally with SSH with the remote space? I know the normal thing to do is to do the git administration on the remote machine--particularly the git init that starts the whole mess. But is it really necessary? Could I set up a .git hierarchy in some directory, and then run all the git operations from my client machine? I don't know what operations git is doing over the SSH link.

You do need git installed on the remote computer (git locally is sshing into the remote and starting git there, then they communicate over the ssh connection).

That said, you can always just mount the remote machine over ssh using sshfs, and then access it with git as though it were a local directory.

E: or have a post-commit hook that rsyncs a local repo to the remote machine

Rocko Bonaparte
Mar 12, 2002

Every day is Friday!

ToxicFrog posted:

You do need git installed on the remote computer (git locally is sshing into the remote and starting git there, then they communicate over the ssh connection).

That said, you can always just mount the remote machine over ssh using sshfs, and then access it with git as though it were a local directory.

E: or have a post-commit hook that rsyncs a local repo to the remote machine
I'm on a Windows box, so this kind of scares me. I found a project called dokan that apparently abstracts out writing arbitrary filesystem drivers for Windows, and there's an sshfs plugin for it. As of this moment, I do have my web hosting account mounted as a drive. I'm now scared shitless of actually trying to go the next step. :ohdear:

Lysidas
Jul 26, 2002

John Diefenbaker is a madman who thinks he's John Diefenbaker.
Pillbug

Rocko Bonaparte posted:

I'm now scared shitless of actually trying to go the next step. :ohdear:

I'd be uneasy about this too. I don't believe Git is designed to work over a network mount like this, and who knows how well the dokan sshfs plugin works.

If msysgit bash actually recognizes the sshfs mount as a drive letter (good luck, by the way), you'll want make sure that your local development repository's .git/config has a remote URL of the form file:///z/path/to/repo.git. The file:// prefix forces Git to use its normal network transfer protocol instead of e.g. trying to hardlink pack files on a local disk.

This is all a horrible idea anyway; why don't you just install Git on your web host machine? (You can SSH into your web hosting and install things, right? You can even install Git into your home directory if you don't have root on the machine.)

ToxicFrog
Apr 26, 2008


Lysidas posted:

I'd be uneasy about this too. I don't believe Git is designed to work over a network mount like this, and who knows how well the dokan sshfs plugin works.

It works fine over sshfs-in-linux (and nfs, for that matter), but I have no idea how the windows one works.

Rocko Bonaparte
Mar 12, 2002

Every day is Friday!

Lysidas posted:

This is all a horrible idea anyway; why don't you just install Git on your web host machine? (You can SSH into your web hosting and install things, right? You can even install Git into your home directory if you don't have root on the machine.)
Ehh kinda. I can SSH into it but there's no git on the plan I had. I had sent a message in tech support about that. I have some web hosting package, and would have to upgrade to a virtual or dedicated host. I'm pondering it, though as an opportunity to re-examine my whole hosting situation.

I have a question about conventions for creating repositories. Today I was trying to get much more into git at work and init'd myself a trash repository. I didn't make it a bare repository, so there was a .git hiding in the path I did the init. In Git Extensions for Visual Studio, I noted it was a public repository when I did the clone command. Somehow in all that, it came through okay. But when I tried again as a private repository, I got poo poo on trying to push changes back up--kind of the generic git message about refusing to fast forward. But if I did it with a bare repo, I would be okay.

So for small team projects hitting a UNIX drive over SSH, is the convention to do a bare repo? Is there really a benefit one way or another? All I can think of is referring to the project path directly instead of project_path/.git.

ColdPie
Jun 9, 2006

Rocko Bonaparte posted:

Ehh kinda. I can SSH into it but there's no git on the plan I had. I had sent a message in tech support about that. I have some web hosting package, and would have to upgrade to a virtual or dedicated host. I'm pondering it, though as an opportunity to re-examine my whole hosting situation.

You can use gitorious or github as your hosting solution. I'm sure you can find something to fit your needs at one of them.

Rocko Bonaparte posted:

So for small team projects hitting a UNIX drive over SSH, is the convention to do a bare repo? Is there really a benefit one way or another? All I can think of is referring to the project path directly instead of project_path/.git.

Bare repositories can't checkout, they just store objects, branches, and tags. That saves disk space and prevents problems like pushing to a checked out branch, or someone mistakenly using the master repo or something.

Wideshanks
May 17, 2007

B.M.O.F.
Big Man On Forums
Did I get this video from this thread?
http://blip.tv/open-source-developers-conference/git-for-ages-4-and-up-4460524

Good content plagued by bad presentation. I got to 19 minutes before I got tired of watching him struggle with the tinkertoys.

Anyone else have some good git (or mercurial, bazaar) videos like this? Something that avoids the really basic stuff like "git add is a command that you use to add st... etc." and dives right into the branching complexity?

I work in an environment that doesn't produce lots of branches so it's hard for me to learn about how it works without tutorials.

Suspicious Dish
Sep 24, 2011

2020 is the year of linux on the desktop, bro
Fun Shoe
There's Federico's git tutorials:

Pushing and Pulling with Git, part 1
Pushing and Pulling with Git, part 2
Why I want to have the children of git rebase --interactive

For something really low-level, you can read Git from the Bottom Up.

Mithaldu
Sep 25, 2007

Let's cuddle. :3:

Wideshanks posted:

Did I get this video from this thread?
http://blip.tv/open-source-developers-conference/git-for-ages-4-and-up-4460524

Good content plagued by bad presentation. I got to 19 minutes before I got tired of watching him struggle with the tinkertoys.

Very likely, since i post it whenever i can. :v: And you're right, the useful bit of it is the first half, then it kinda falls apart. However, the first half already gives you a massive advantage over a SVN dude trying to transition on his own.

As for branches, the easiest way to learn about them is to try and do an interactive rebase manually:

1. pick a commit in the past you want to edit
2. set a new branch marker on the commit 2 before that one and check it out
3. cherry-pick the two commits before the one you want to edit
4. cherry-pick the one you want to edit, edit code and make a --amend commit
5. go through and cherry-pick each of the following ones, resolving conflicts as you go
6. reset --hard the master branch tag to the HEAD of your new branch
7. delete the new branch tag you made previously
8. push --force

Now you know everything you need to know about branches.

ufarn
May 30, 2009
Why is it that, on Windows 7, `git diff` sometimes returns absolutely nothing? Makes it hard to see what's changed ...

Second, is there really no way to prevent git from interpreting removed or added as completely new documents, where everything is -'d and +'d?

Mithaldu
Sep 25, 2007

Let's cuddle. :3:

ufarn posted:

Why is it that, on Windows 7, `git diff` sometimes returns absolutely nothing? Makes it hard to see what's changed ...
Never had that happen, and anyhow, you want to run git gui for that because it lets you easily get an overview on both your working directory and the index.

ufarn posted:

Second, is there really no way to prevent git from interpreting removed or added as completely new documents, where everything is -'d and +'d?
No, that's how git works. Adding a document means adding lines under a tree entry that previously had none and removing a document means removing all lines from an existing tree entry.

ufarn
May 30, 2009

Mithaldu posted:

Never had that happen, and anyhow, you want to run git gui for that because it lets you easily get an overview on both your working directory and the index.
git gui says it can't detect any changes as well. I think the fact that I turned on another computer which has the same folder in Dropbox bungled something. I guess I can use `git checkout` on the affected files.

Wideshanks
May 17, 2007

B.M.O.F.
Big Man On Forums

Suspicious Dish posted:

For something really low-level, you can read Git from the Bottom Up.

Ah, this is perfect, thank you.

Cool command--get a list of each of the objects in your repo and what type they are:

find .git/objects -type f | awk 'BEGIN{FS="/"}{print$3$4}' | while read -r hash; do git cat-file -t $hash; done

ToxicFrog
Apr 26, 2008


Suspicious Dish posted:

For something really low-level, you can read Git from the Bottom Up.

I'm also fond of Git for Computer Scientists for a good look at how branches etc work internally without getting sidetracked by implementation details.

Lysidas
Jul 26, 2002

John Diefenbaker is a madman who thinks he's John Diefenbaker.
Pillbug

Wideshanks posted:

Ah, this is perfect, thank you.

Cool command--get a list of each of the objects in your repo and what type they are:

find .git/objects -type f | awk 'BEGIN{FS="/"}{print$3$4}' | while read -r hash; do git cat-file -t $hash; done

FYI this only examines loose objects, i.e. those that aren't stored in a pack file. (A few git commands run git gc --auto after they complete, and this will consolidate loose objects into a pack file if there are too many. You can also manually pack your loose objects with git repack.)

EDIT:
code:
fatal: Not a valid object name packpack-265968c856973bfe79185a5c591d9317b8bb92e4.pack
fatal: Not a valid object name packpack-265968c856973bfe79185a5c591d9317b8bb92e4.idx
fatal: Not a valid object name infopacks

Adbot
ADBOT LOVES YOU

Wideshanks
May 17, 2007

B.M.O.F.
Big Man On Forums

Lysidas posted:

FYI this only examines loose objects, i.e. those that aren't stored in a pack file. (A few git commands run git gc --auto after they complete, and this will consolidate loose objects into a pack file if there are too many. You can also manually pack your loose objects with git repack.)


Yeah, I noticed that. I guess it's useful only for learning purposes with a small testing repo: I thought it was nice to see what objects were created when I ran a command. Run git add, then see it add the blob. Do git commit and then see the commit object pop up.

Edit:
Is there a way to use hg-style shortcuts for the unambiguous commands in git? E.g. type "git co" for "git commit" / "git stat" for "git status"?

Wideshanks fucked around with this message at 18:53 on Jan 29, 2012

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply