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
necrotic
Aug 2, 2005
I owe my brother big time for this!

Plorkyeran posted:

git rebase -i B, delete the line for C, save and exit.

It sounds like he wants to keep the changes. Step 3 in his example (diff between B and D) would include the changes in C. Instead of deleting the commit from the rebase UI he should squash (or fixup) it.

Adbot
ADBOT LOVES YOU

necrotic
Aug 2, 2005
I owe my brother big time for this!

oiseaux morts 1994 posted:

Don't want to keep changes in C. But of course D would have them, I want what D changed but not C. Presumably interactive rebase as stated does that

Then yeah, what Plorkyeran said. I was reading your step 3 as `git diff B D` which would have included the C changes.

necrotic
Aug 2, 2005
I owe my brother big time for this!

Doc Hawkins posted:

I love rebase, but if anyone else has pulled this branch, you'd be better off using `git revert C` to make a new commit which cancels out whatever C did.

Unless C added plaintext passwords or something.

Yeah, you should only rebase (or any kind of history changes) on "private" branches.

necrotic
Aug 2, 2005
I owe my brother big time for this!

Jethro posted:

And even if git makes it easy to screw that up, I'm still not convinced that using dropbox instead of github (or whatever) makes much sense. If you make changes on machine A, sync them to dropbox, and then can't get to dropbox from machine B for whatever reason, it seems like it would be a pain in the rear end to merge any changes you do on machine B once you can get to dropbox, whereas doing that with an external repo is what a DVCS is for.

Wasn't he talking about putting a repo in dropbox? A simple "private server" that only really works for one person.

necrotic
Aug 2, 2005
I owe my brother big time for this!

Strong Sauce posted:

It seems a bit insane. Why not just use BitBucket if you don't want to pay, or GitHub if you're willing to pay $7/month for 5 repos? Seems like a lot of time better spent writing more apps.

Setting up gitolite on a small VPS is incredibly simple. If you need anything more than what Gitolite offers (pull requests and such) there are open source offers (GitLab HQ) that work fairly well and can be simple to setup if you have experience with Rails.

A half day of effort tops to save a 2-person shop $84/year (does Bitbucket's free plan allow you to share private repos? I thought it didn't...)

necrotic
Aug 2, 2005
I owe my brother big time for this!

wwb posted:

Bitbucket gives you free private repos for up to 5 private users, you need to pay beyond that.

I didn't realize you could have 5 users on the free accounts.

necrotic
Aug 2, 2005
I owe my brother big time for this!

Yeah, reset only touches tracked files. Untracked files are handled with clean (although its not restricted to untracked files).

necrotic
Aug 2, 2005
I owe my brother big time for this!

aerique posted:

Who here is using Git in a larger organization with more than, say, 50 or 100 developers? Do you use something like GitLab for managing users and repositories?

We have ~60 developers using Git in our organization. Currently we're on GitHub, but we have plans to move off to something else (maybe Stash, we already use Jira).

necrotic
Aug 2, 2005
I owe my brother big time for this!

NOTinuyasha posted:

Bet it's a lot of fun when Github.com goes down for hours at a time, like yesterday. We use Github too but we're only three developers so our budget is tight, if we were any larger we'd totally rather have our own Gitlab server rather than be subject to Github's occasional but extremely annoying service problems.

This was a problem for us when our deploy system simply checked out code from github.com on all 500+ of our servers.

We build a slug on one box and ship it out to the rest now. Amazing how many problems that solved.

necrotic
Aug 2, 2005
I owe my brother big time for this!

Hughlander posted:

How do you keep that up to date vs github? IE: I'm an engineer I push to github and want to see a build kicked off within seconds. Does kicking off the build start with the slug pulling from github then notifying the 500+ servers?

We don't do continuous deployment yet, just integration tests. A deploy to all 500+ servers has a bit of process behind it...

Sailor_Spoon posted:

That's pretty much what we have. A push to github triggers a jenkins job which pulls from github, builds everything, then pushes (SCP, I think) everything out to each server. This relies on having the jenkins server be build identically to the production servers, but that's what puppet is for.

Something similar to this. Any new PR (or changes to a PR) triggers a build on Jenkins for our testing platform, and when changes are ready for prod our team merges PRs into a release branch that also triggers a build. We then use an in-house tool to push the slug out to all of our servers (or a single facet, or a single server in each facet, or a percentage of servers, etc...). We plan on releasing the tool at some point to the public, but it's still changing a lot so thats some ways away yet :(

edit: Also, chef is the workhorse. If a new server spins up (EC2 auto scalers) it knows how to fetch the current production slug and install it. Once a server spins up Chef only does a few maintenance tasks (around user access and such).

necrotic
Aug 2, 2005
I owe my brother big time for this!
It looks like you're creating 2.5.1 as a branch and not a tag, though. Are you tagging it later on? I think if you have a branch and a tag with the same name it has issues with ambiguity when you try to checkout that ref.

code:
warning: refname '2.5.1' is ambigous.
Not sure what it would pick in this case, and I've never tried it myself. Other than that it looks like a reasonable approach.

For your second question, you can merge in the tag if you have a multiple engineers working on the branch:

code:
git checkout 2.6.0
git merge 2.5.1
If you alone are working on it and other people are not dependent on the state of 2.6.0 you can rebase it onto 2.5.1:

code:
git checkout 2.6.0
git merge 2.5.1
However, there is an even better way:

1. Master is the "stable" branch. In your case this would be 2.5.0 at the start.
2. Develop is the "unstable" branch. New work for 2.6.0 should be merged here when completed.
3. When you need to make bug fixes for 2.5.x you create a branch based off of master (or the tag, but master should always be the latest stable tag), do your testing with this branch, etc... When you're done with the fixes and they are verified you can merge that branch back into master and tag as 2.5.1.
4. To get changes into develop you have two options: (1) rebase develop onto master. As people should not be working directly on this branch it should not disrupt peoples flows. If someone working on a feature requires the bugfix they can now rebase on develop. (2) simply merge it into develop. The downside of this now develop will have a merge commit at a later point than master.

I personally like the first option under 4, but I think people have pretty varying opinions on this.

necrotic
Aug 2, 2005
I owe my brother big time for this!

hirvox posted:

https://www.atlassian.com/git/tutorial/rewriting-git-history

Have you modified your .gitconfig to use your favourite diff/merge tool and your favourite editor? Rebasing in itself is not complicated; It just tries to reapply the changes to a different point in the commit tree. Because the commits are merged one at a time, fixing conflicts should be easier than during a full merge. But if you don't see clearly what you're doing, it's easy to treat rebasing as black magic. Oh, and don't be afraid to use git rebase --abort if you feel like you've painted yourself into a corner.

For someone who hasn't done a rebase before the concept can be a little strange. I like the verbage they use when you start: "First, rewinding head to replay your work on top of it...". Tells you exactly what rebase does.

necrotic
Aug 2, 2005
I owe my brother big time for this!

Marsol0 posted:

The repo doesn't care. I guess github might, though. Seems silly to me.

GitHub doesn't really care either. But if you remove a fork then it can no longer be a remote, so changing it to "unknown repository" makes sense.

necrotic
Aug 2, 2005
I owe my brother big time for this!

caiman posted:

Newbie git question. Why does checking out a commit result in the "detached HEAD" state? If I do "git checkout . " my working directory simply gets changed to look just like the repo, so why doesn't "git checkout <sha>" simply make my working directory look like that commit? Why act like a new branch?

http://gitolite.com/detached-head.html might be of some help. Specifically:

quote:

HEAD is, normally, a symbolic reference to [the tip of] a branch. For instance, if you do cat .git/HEAD on a brand new repository, you'll get back ref: refs/heads/master. When you add a commit, git actually updates 'master', because that's where HEAD points. You can see this by doing cat .git/refs/heads/master before and after making a commit. HEAD does not change (it's only a symbolic reference) but 'master' does.

When you do a git checkout branchname, HEAD will now become a symbolic reference to 'branchname'. This means cat .git/HEAD will return ref: refs/heads/branchname now. New commits will now go on 'branchname' instead of master, and correspondingly, the contents of .git/refs/heads/branchname will change.

However, when you checkout anything that is not a proper, local, branch name, then HEAD is no longer a symbolic reference to anything. Instead, it actually contains the SHA-1 hash (the commit id) of the commit you are switching to.

This is called a detached HEAD.

necrotic
Aug 2, 2005
I owe my brother big time for this!

caiman posted:

Thanks guys, that's the reasonable explanation I was looking for.

Regarding the output of 'git log --graph --decorate --all', is there a good resource that might help me learn to decipher what I'm seeing? It's very pretty, but I can' t make heads or tails out of it.

The far left line is the branch you are on, all of the forking "branches" are just that: branches (demarcated by merge commits). The reason you can have multiple lines is multiple branches created at different points off the base tree. Oh, and each * is an actual commit, the dashed lines are just visual so you can follow.

necrotic
Aug 2, 2005
I owe my brother big time for this!

Seashell Salesman posted:

Is there a way, in Git, to checkout the commit at the head of a branch (not by looking up the hash) so that you end up with detached head? Sometimes for bug fixes I want to just get to the head of a team branch and start committing stuff and create a branch for the fix later, and I'm sick of having to reset --hard my copy of the team branch afterwards. This workflow just works when I'm working off a tag instead of a branch so I feel like there is a way to do it without too much pain.

git checkout -b new-branch-name shared-branch-name creates a new branch named "new-branch-name" with the same HEAD as "shared-branch-name". https://git-scm.com/docs/git-checkout

necrotic
Aug 2, 2005
I owe my brother big time for this!

Seashell Salesman posted:

Put it another, maybe less confusing way, 'git checkout A' then 'git commit' will move me to the head of A, create a new commit, and then make A point to the new commit. I don't want A to point to the new commit, and I don't want to create a new branch or have to look up the hash for the head of A beforehand.

I'm curious why you would even want to do this.

necrotic
Aug 2, 2005
I owe my brother big time for this!

fletcher posted:

What's your favorite mergetool on linux? I've been using kdiff3, wondering if there's anything else I should check out.

p4merge is amazingly good.

necrotic
Aug 2, 2005
I owe my brother big time for this!

Edison was a dick posted:

Yeah, if you want to do sparse checkout, it's a per repository clone option, and you have to do it before checking out, so it's a PITA.
http://phatblat.com/blog/2014/09/14/git-sparse-checkout/ seemed to be the best documentation I could find on getting it to work, since it wasn't very clear in the manpages from what I could find.

When you check out part of a tree in SVN you don't get the entire repository, though. This method you still fetch *everything*, but the checkout will only be that sub-tree. Semantically it will look the same, but if the point is to save space or bandwidth this won't help.

necrotic
Aug 2, 2005
I owe my brother big time for this!

ToxicFrog posted:

I delete the branches, but I don't know how universally true that is.

I believe its all over the place. For example, some people in my company delete branches after merging; others leave them around for ever! I recently went through and pruned a bunch of merged branches and killed off ~8k of them. But it doesn't really matter with how cheap branches are if you have a decent scheme for naming them.

necrotic
Aug 2, 2005
I owe my brother big time for this!

22 Eargesplitten posted:

Another question, can github be searched for file names or project names? I'd like to be able to link stuff in a github made for this account, but I don't want to make it easier to doxx me than it probably already is. I use my real name for my github repository name currently.

They have a search mechanism. And if its public external search engines will find it, too.

necrotic
Aug 2, 2005
I owe my brother big time for this!

Lumpy posted:

Because I'm a git idiot (gitiot?) you are saying that because I put the URL in to my push, the code went up, but the remote didn't sync because of it because a fetch never happened to my local.

So, how do I un-gently caress the multiple sets of commits? I certainly can live with it being there, I just want to learn me more git.

git fetch origin

necrotic
Aug 2, 2005
I owe my brother big time for this!

Ciaphas posted:

git rebase master warnings-fixes

You actually want git rebase origin/master, assuming the remote is named origin, while you have the warnings-fixes branch checked out.

quote:

will replay all of the commits uniquely reachable by warnings-fixes on top of where master currently is, and save them as new commits, correct?

Yes.

quote:

Does anything in particular happen to the old commits in that branch?
The SHAs will exist in the reflog until the next gc run (unless another branch starts to reference them)

quote:

Is this different if there's a remote-tracking or another local branch there before I do the rebase?
Another branch where? git rebase doesn't really care what the source is, as long as the destination is a local branch.

quote:

Will rebasing in this way interfere with anyone?

Only if its a shared branch. If you rebase they will have to force reset their local copy of the branch instead of a simple pull.

quote:

My guess is "yes, this is what you want; they are brand new commits; the old ones are orphaned unless another branch, remote or otherwise, was at the head before you rebased; it won't interfere with anyone long as you've never pushed warnings-fixes". Is that about right?

Heh, I read this last. Yeah, that's exactly it.

necrotic
Aug 2, 2005
I owe my brother big time for this!

ufarn posted:

Is there a simple way to make gh-pages the default branch for your GitHub repo? I can't find a simple, canonical way to do it.

https://github.com/ORG/REPO/settings/branches

You should be able to select it there.

necrotic
Aug 2, 2005
I owe my brother big time for this!

Ciaphas posted:

Still wondering this, and have a followup question. Someone pushed a couple of commits up to our central repo with the wrong email address (the default, basically, because they forgot to configure it on their new system). If I use filter-branch or whatever to try to fix that on the central, is that going to mess up everyone who's already pulled down the new commits (like rebasing a pushed branch would)?

Yes, you're effectively rewriting history so the same issues apply. Unless its a major problem I'd leave it.

necrotic
Aug 2, 2005
I owe my brother big time for this!

uXs posted:

Is there some way in Git to just checkout the latest commit, skipping over all the intermediate ones?

I had some coworkers commit things with paths beyond the maximum Windows path length, and now I can't get to the latest version, which doesn't have those files anymore.

A shallow-clone should pull only the latest commit, but eventually I think you need the rest of the history? I haven't really looked into shallow clones.

necrotic
Aug 2, 2005
I owe my brother big time for this!

Boris Galerkin posted:

So I'm actually browsing our git repository on our gitlab site and holy poo poo this UI is a loving disaster. I have/had my browser snapped to one side/half of my monitor so the ~responsive design~ decided to get rid of all the labels on the menu bar on the left. Maybe I'm just too old (I'm 28...) but the icons they decided to use make no god drat sense to me and aren't very intuitive, specifically the activities (speedometer), milestones (a loving clock), merge request (a server rack??), and snippets (pieces of paper). I tried to look for a way to change my settings to maybe see if it can just force display the labels so I clicked on 'profile settings' but wasn't expecting the sidebar to replace the icons with different options so I spent 10 seconds of my life upset that "profile settings" literally only lets me change my profile information before realizing the sidebar changed.

Now I wasted a minute of my life posting this.

Is there a userscript I can install or something to change the entire UI to Github's UI? I mean that one at least makes perfect sense and I'm used to it.

Doubt there's a full "Github UI" script. Gitlab does have a lovely UI, though. It was way better before they did the overhaul.

necrotic
Aug 2, 2005
I owe my brother big time for this!
That sounds like a reasonable approach. Just try to keep it to one or a few commits so if they enter conflict hell it's not as bad.

necrotic
Aug 2, 2005
I owe my brother big time for this!
It's apparently an Enterprise feature.

https://docs.gitlab.com/ee/user/project/merge_requests/fast_forward_merge.html

necrotic
Aug 2, 2005
I owe my brother big time for this!
There's also a plugin that checks all config changes into a git repo for you. We had to disable it for some issues I think though and I forget the plugin name at the moment. But there are ways to track he Jenkins changes.

necrotic
Aug 2, 2005
I owe my brother big time for this!
I was going to recommend letting the branches build out and reseting the empty master to whatever the trunk branch was.

Master is purely convention in git it's not even a requirement.

necrotic
Aug 2, 2005
I owe my brother big time for this!

Thermopyle posted:

Why are they in the same repository at all?

If they all unrelated this is the correct way.

Axiem posted:

But Google puts everything in one repo!

Yeah, because they are all intertwined. My last job had a bunch of lovely microservices that all dependend on each other in separate repos and adding new features across them was the worst.

necrotic
Aug 2, 2005
I owe my brother big time for this!
Should be relatively straight forward with subtrees: https://git-scm.com/book/en/v1/Git-Tools-Subtree-Merging

necrotic
Aug 2, 2005
I owe my brother big time for this!
Not new in the direct sense, but a replacement yes. The previous chapter of that book tries to do the same thing with submodules as a setup for the subtree chapter.

necrotic
Aug 2, 2005
I owe my brother big time for this!
They'll have to copy the file somewhere else locally beforehand, or use something like this after pulling down your commit:

code:
git show SHA_WITH_FILES_STILL_EXISTING:path/to/the/dumb/file > path/to/the/dumb/file

Snak posted:

I'm thinking there should be some way to do what you're wanting to do by adding those files to the .gitignore file. But I'm​ not sure what the interaction is if they don't have the updated gitignore before they pull the changes that remove the files...

.gitignore only matters for adding files to your stage. If you ignore a file already in the tree it will prevent adding changes to the file without the force flag. It won't help for what he wants (although those files should 100% be added to the gitignore so it doesn't happen again).

necrotic
Aug 2, 2005
I owe my brother big time for this!
Change the file to some ridiculous settings so they see the problem with it as is.

necrotic
Aug 2, 2005
I owe my brother big time for this!
edit: nevermind, that was not what I thought it was! Yeah, that's dumb.

necrotic
Aug 2, 2005
I owe my brother big time for this!
Yeah just use bitbucket for that as you get free private repos.

necrotic
Aug 2, 2005
I owe my brother big time for this!
Does the hook file have an extension? They have to be hook-name exactly, no extensions. Hooks can be any executable file, as long as the name matches.

If it's a shell script (or any other interpreted file) you need a shebang at the top declaring the interpreter.

If the name is correct I'd sprinkle some debug statements in the script and make sure they are output.

edit: added some more.

necrotic fucked around with this message at 23:46 on Jun 19, 2017

Adbot
ADBOT LOVES YOU

necrotic
Aug 2, 2005
I owe my brother big time for this!

Boris Galerkin posted:

I'm using Git LFS with my Bitbucket account and I noticed I have a few large binary files that still show up in the LFS storage online but I'm 99% sure that I've deleted them and don't need them anymore. Is my understanding correct that these files still show up in the LFS repository simply because some old commit(s) reference them? If so I would like to just delete them from the website interface to free up some limited LFS space I get.

I'm not familiar with LFS usage, but with git in general it is the case that a "deleted" file still exists in the history. You have to use filter-branch to go back through history and delete the files from every previous commit, thus building an entirely new history. This also means the repo will be 100% out of sync with anyone else using it.

GitHub has a pretty good article on removing files completely: https://help.github.com/articles/removing-sensitive-data-from-a-repository/

All of it should apply to LFS as well.

Boris Galerkin posted:


Follow up question, is there a more "git" way to remove these files from the command line? Like some kind of git lfs prune or similar command?

All git commands should work against LFS files, right? So git rm the/file.bin and then commit the deletion.

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