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
Seashell Salesman
Aug 4, 2005

Holy wow! That "Literally A Person" sure is a cool and good poster. He's smart and witty and he smells like a pure mountain stream. I posted in his thread and I got a FANCY NEW AVATAR!!!!

22 Eargesplitten posted:

I'm in Git Bash on windows and after that message came up, it won't respond to my typing. I did this the first time I tried to commit anything and just exited out and did it again correctly, but I'd like to know how to get out of it without doing that.

This is what I'm getting, with the list of files I'm committing underneath.



Right. This is vim which should be the default editor for git, if you want to learn how to use it then Google 'vim'. You can change it to notepad or whatever you like with git config --global core.editor "path-to-editor"

Adbot
ADBOT LOVES YOU

raminasi
Jan 25, 2005

a last drink with no ice

22 Eargesplitten posted:

:wq did it, thanks.

Yet another question. My master branch on github is extremely messy. Is it possible to delete the contents for the current commit and push the new, cleaned up folder? I already branched the current version off in case I end up needing something from it.

I assume you mean the history is extremely messy. If it's really bothering you, you can get your local history however you want it and then force-push to overwrite the server copy. But don't do this if anyone else is tracking that branch for anything; it will totally bork the workflow of every single person who relies on it other than you. Rewriting public history is generally considered Extremely Bad Form.

22 Eargesplitten
Oct 10, 2010



GrumpyDoctor posted:

I assume you mean the history is extremely messy. If it's really bothering you, you can get your local history however you want it and then force-push to overwrite the server copy. But don't do this if anyone else is tracking that branch for anything; it will totally bork the workflow of every single person who relies on it other than you. Rewriting public history is generally considered Extremely Bad Form.

Sorry I wasn't clear. I've got a bunch of redundant and unnecessary files that make the filesystem stored in Github look awful and make it difficult to navigate. I sorted it out locally, and want to fix it on git. But if I try to push the fixed files to github, it says that the push has been denied because the repository contains work that I do not have locally.

Do I need to start an empty folder, connect it to the repository, pull, rm -rf, and then push the new version to Github?

New Yorp New Yorp
Jul 18, 2003

Only in Kenya.
Pillbug

22 Eargesplitten posted:

Sorry I wasn't clear. I've got a bunch of redundant and unnecessary files that make the filesystem stored in Github look awful and make it difficult to navigate. I sorted it out locally, and want to fix it on git. But if I try to push the fixed files to github, it says that the push has been denied because the repository contains work that I do not have locally.

Do I need to start an empty folder, connect it to the repository, pull, rm -rf, and then push the new version to Github?

Git commits are immutable. When you rewrite history (e.g. amend commits, rebase, filter-branch), you actually throw out the old commits and create new commits in their place with new hashes. If you rewrote history, you have to force push.

22 Eargesplitten
Oct 10, 2010



I must be misunderstanding something. I don't want to change past commits, I just want to put in a new commit without some of the folders and files that aren't necessary anymore. I don't mind older commits having all of them. I haven't rewritten anything at this point, and I don't want to take anything out of current commits, I just don't want to bring some stuff over into the new commit.

VikingofRock
Aug 24, 2008




22 Eargesplitten posted:

Sorry I wasn't clear. I've got a bunch of redundant and unnecessary files that make the filesystem stored in Github look awful and make it difficult to navigate. I sorted it out locally, and want to fix it on git. But if I try to push the fixed files to github, it says that the push has been denied because the repository contains work that I do not have locally.

Do I need to start an empty folder, connect it to the repository, pull, rm -rf, and then push the new version to Github?

22 Eargesplitten posted:

I must be misunderstanding something. I don't want to change past commits, I just want to put in a new commit without some of the folders and files that aren't necessary anymore. I don't mind older commits having all of them. I haven't rewritten anything at this point, and I don't want to take anything out of current commits, I just don't want to bring some stuff over into the new commit.

It sounds like what happened is that someone did some work on the remote repository, which you don't have mirrored locally. This occasionally happens to me even on my solo projects, where I'll have done some work on one computer, and then pushed it to github, and then I'll have forgotten to do a fetch/merge on a second computer before doing work on that second computer. If you think that's what happened, the easiest fix is to do a git pull --rebase. This will find the most recent common ancestor of the work on your computer and the work on the remote computer, pull down the changes from the remote, and then apply your changes (i.e. deleting the extraneous files) on top of the remote's changes.

22 Eargesplitten
Oct 10, 2010



Yep, I just needed to pull to get it synced up and then push again.

But now I've got another problem. When I commit, it doesn't move the head to the newest commit. And when I try to push to github, it goes through the normal ssh username/password thing but doesn't update anything. It says I'm currently in detached head mode, does that have to do with it?

I pulled the most recent version, deleted all of the files and replaced them with the updated files / file system, is that where I broke it?

E: I cherry picked the one commit that was detached from the head and that fixed it. I'm glad git is so resilient to me fumbling around.

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.

22 Eargesplitten fucked around with this message at 21:32 on Feb 8, 2016

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.

Tarion
Dec 1, 2014

22 Eargesplitten posted:

:wq did it, thanks.

Yet another question. My master branch on github is extremely messy. Is it possible to delete the contents for the current commit and push the new, cleaned up folder? I already branched the current version off in case I end up needing something from it.

Read the docs for 'git reset', specifically, 'git reset HEAD~' and 'git reset --hard HEAD~' (be careful with this one).

Cancelbot
Nov 22, 2006

Canceling spam since 1928

I'm leaving a 100% mercurial shop (and my last place was also mercurial) to a 100% git shop.

Are there guides on making this switch without loving up badly? Or at least the key differences, I only really know of branches being pointers and the fun that brings with remotes.

MrPablo
Mar 21, 2003

Cancelbot posted:

I'm leaving a 100% mercurial shop (and my last place was also mercurial) to a 100% git shop.

Are there guides on making this switch without loving up badly? Or at least the key differences, I only really know of branches being pointers and the fun that brings with remotes.

push and fetch do the opposite things in git, commit needs the -a flag to behave like mercurial, and there are no command-line shortcuts by default. I use the following .gitconfig:

code:
[core]
  excludesfile = ~/.gitignore
[color]
        ui = auto
        diff = auto
[alias]
        st = status -s
        di = diff HEAD
        ci = commit
        co = checkout
        br = branch
        l = log --oneline
        lo = log --oneline --decorate
        ls = log --oneline --decorate --stat
[user]
        email = [email]foo@example.com[/email]
        name = Your Name
[color "diff"]
        whitespace = red reverse
There are a handful of other differences between Git and Mercurial as well, but if you read through the online version of Pro Git you should be just fine.

ExcessBLarg!
Sep 1, 2001
I haven't really used Mercurial for five years, but the biggest difference when I went from Mercurial to Git was the practice and degree of history rewriting.

For quite some time history rewriting was a limited, if not impossible practice in Mercurial. It's a fundamental distinction between Mercurial and Git that dates back to their original design, with Mercurial adopting a diff-based structure (revlog) for its internal storage on the basis that the primary purpose of the tool is to preserve revision history, although many folks used the mq extension as a means of local rewriting/reordering of private changesets.

In Git, commit history modification is a fundamental feature supported by core commands (e.g., commit --amend, rebase -i, reset, etc.), so the equivalent of managing a patch queue is to maintain a set of local commits at the top of history, rebasing them on remote changes. In general, local history rewriting (rebasing, squashing commits) is an encouraged practice with Git, since one of the fundamental points of revision control is to communicate changes to others, in addition to preserving their (public) history. So it's probably best to think of the funny/"dangerous" git commands as analogous to those of the mq extension. If you've never used mq (or rebase, or whatever) then you may want to read up on the benefits of local history rewriting in the first place.

The other two major differences is the distinctions between named branches (Git's branches function like Mercurial bookmarks, and are not encoded in revision history), and Git's explicit distinction between remote and local branches.

MrPablo
Mar 21, 2003

ExcessBLarg! posted:

I haven't really used Mercurial for five years, but the biggest difference when I went from Mercurial to Git was the practice and degree of history rewriting.

For quite some time history rewriting was a limited, if not impossible practice in Mercurial. It's a fundamental distinction between Mercurial and Git that dates back to their original design, with Mercurial adopting a diff-based structure (revlog) for its internal storage on the basis that the primary purpose of the tool is to preserve revision history, although many folks used the mq extension as a means of local rewriting/reordering of private changesets.

In Git, commit history modification is a fundamental feature supported by core commands (e.g., commit --amend, rebase -i, reset, etc.), so the equivalent of managing a patch queue is to maintain a set of local commits at the top of history, rebasing them on remote changes. In general, local history rewriting (rebasing, squashing commits) is an encouraged practice with Git, since one of the fundamental points of revision control is to communicate changes to others, in addition to preserving their (public) history. So it's probably best to think of the funny/"dangerous" git commands as analogous to those of the mq extension. If you've never used mq (or rebase, or whatever) then you may want to read up on the benefits of local history rewriting in the first place.

The other two major differences is the distinctions between named branches (Git's branches function like Mercurial bookmarks, and are not encoded in revision history), and Git's explicit distinction between remote and local branches.

In Mercurial, commit has an --amend flag just like Git, and newer versions of Mercurial support limited history editing with the histedit extension.

Otherwise these are all excellent points, particularly the fact that rewriting local history to remove cruft is encouraged (and even expected, depending on the project) in Git.

Cancelbot
Nov 22, 2006

Canceling spam since 1928

Ah that's great stuff! They tried to introduce rebasing and squashing where I currently work and it caused so much consternation due to not being "mercurial-like" that I didn't bother looking it up for a while. But it makes a lot of sense especially when you're pull request driven and need to make sense of the many little commits you often do in DVCS systems.

The other thing I've had to pay attention to is leaving master alone except for merging into; as much as I buy into feature toggles/branch by abstraction the vast majority of software teams I know of use feature/PR based approaches. But the branching stuff with git is so lightweight its not a problem to work that way.

smackfu
Jun 7, 2004

How do people do code review in a svn system? Mailing patches around seems terrible, especially if you are doing continuous integration.

My last project we were using RTC (Rational something something) which I found very confusing in the big picture but did have a very clear concept of change sets that were tied to a work item and needed to be reviewed before being committed.

ExcessBLarg!
Sep 1, 2001
Before distributed version control became popular, folks would email patches to someone with commit rights. It wasn't great, but it wasn't so bad either as it forced everyone (submitter, committer) to review the diff itself, and generally time would be taken to ensure the patch was high quality (squashed, good commit message, no unrelated changes, etc.).

In my experience, though, when everyone does have commit rights in a centralized system, code reviews just aren't done. Fundamentally reviews are post commit and you have to slog through multiple not-well-done commits, and there's a lot more inertia to making post-review changes because it's "already in SVN".

Plorkyeran
Mar 22, 2007

To Escape The Shackles Of The Old Forums, We Must Reject The Tribal Negativity He Endorsed
The correct answer is to use something like Gerrit or Phabricator, which gives you a workflow similar to github PRs (except much better, because github PRs are basically babby's first code review tool).

uXs
May 3, 2005

Mark it zero!
We do commits in feature branches, and when a feature is done someone else reviews the work + merges it into default.

Blinkz0rz
May 27, 2001

MY CONTEMPT FOR MY OWN EMPLOYEES IS ONLY MATCHED BY MY LOVE FOR TOM BRADY'S SWEATY MAGA BALLS

uXs posted:

We do commits in feature branches, and when a feature is done someone else reviews the work + merges it into default.

Yeah this is basically the right way to use GitHub.

Ciaphas
Nov 20, 2005

> BEWARE, COWARD :ovr:


I've got a situation where I'm trying to maintain a repository for two OSes--SunOS and RHEL, in this case. 95%+ of the code and scripts and stuff is the same between the two. I figure I can set up a git repo with linux and sun branches, but that would mean doing two merges for every commit that applies to both branches. Does anyone have any experience with this sort of problem that they can enlighten me with?

New Yorp New Yorp
Jul 18, 2003

Only in Kenya.
Pillbug

Ciaphas posted:

I've got a situation where I'm trying to maintain a repository for two OSes--SunOS and RHEL, in this case. 95%+ of the code and scripts and stuff is the same between the two. I figure I can set up a git repo with linux and sun branches, but that would mean doing two merges for every commit that applies to both branches. Does anyone have any experience with this sort of problem that they can enlighten me with?

Assuming Git: Can't you put the common code in a separate repository and have distribution-specific repositories that use submodules to pull in the common code?

Ralith
Jan 12, 2011

I see a ship in the harbor
I can and shall obey
But if it wasn't for your misfortune
I'd be a heavenly person today
Normally you try to have a single set of code that can be configured at compile time or even run time to support any of the supported target platforms.

New Yorp New Yorp
Jul 18, 2003

Only in Kenya.
Pillbug

Ralith posted:

Normally you try to have a single set of code that can be configured at compile time or even run time to support any of the supported target platforms.

I was just assuming that the code was substantially different, so much so that doing it via precompilation would be difficult to maintain.

Ralith
Jan 12, 2011

I see a ship in the harbor
I can and shall obey
But if it wasn't for your misfortune
I'd be a heavenly person today

Ithaqua posted:

I was just assuming that the code was substantially different, so much so that doing it via precompilation would be difficult to maintain.
So you just put that bit in a different file and use your build system to choose the right one for a given target. This is more or less how every portable project I've ever seen works.

Ciaphas
Nov 20, 2005

> BEWARE, COWARD :ovr:


Ralith posted:

Normally you try to have a single set of code that can be configured at compile time or even run time to support any of the supported target platforms.

Unfortunately there are things like shell scripts using builtins that, no matter how I slice it, just have to be different between the two systems. Process monitoring stuff comes to mind right now. As to the actual C++ code, some of the differences already use directives and such, but most don't, and those aren't gonna be worth the effort to refactor for the timeframe I have to do this for (a couple months at best).

Ithaqua posted:

Assuming Git: Can't you put the common code in a separate repository and have distribution-specific repositories that use submodules to pull in the common code?

Git, yes, sorry. That might work, though I've never used submodules before so there might be some faff.

The other half of that problem is that, as part of moving from Sun to Linux, we're moving off of Clearcase (:suicide:) so adapting to things like submodules might be a bit much for the rest of my team. And me for that matter :v:

ExcessBLarg!
Sep 1, 2001
Git submodules will work if all the common code is confined to a common directory inside the platform specific code, otherwise you have to go with branches or separate repos with a shared remote. Submodules also kind of suck for making sure that everyone fetches and pushes from all repos, so it does require some discipline, but much of it can be scripted to make it easier.

If you go the branch route, the easiest way to do it is to have all the common code on a "common" (or master) branch, and platform specific code on separate "sun" and "linux" branches into which you regularly merge changes made to the "common" branch. But this means you have to switch to "common" to make any changes to common code, then switch to each branch to merge those changes in. The upshot is that auto-merges will largely just work so you won't have much in the way of merge conflicts to resolve. The downside is that you have to switch branches all the time, and if people lack the discipline to commit common changes to the "common" branch, you'll find yourself frequently with changes on one of the two platform-specific branches that have to be cherry-picked back into "common" and merged onto the other branch. Whatever you do though, don't merge from a platform-specific branch to "common", that will ruin your day.

The other approach is to pick a platform that you'll primarily support, say "linux", and merge changes from "linux" back into "sun". So long as most of the changes are to the common code, merging won't be a big deal, but anytime you do merge platform-specific changes you'll want to do a manual merge as an auto-merge will incorrectly leak "linux" code into the "sun" branch. Hence, this approach is riskier, but if you basically don't have much in the way of platform-specific code and can deal with the "sun" branch lagging behind, it can be made manageable.

Honestly, though, the best option is to have one branch and conditionally-compile platform-specific code. Even with shell scripts, you can usually have a "foo-linux.sh" and "foo-sun.sh" which are called by a master "foo.sh" after determining which OS you're on.

Stinky_Pete
Aug 16, 2015

Stinkier than your average bear
Lipstick Apathy
What's the fastest way for me to go from seeing a file in my Windows file browser, to having the file's SVN path on my clipboard? I'm doing a lot of requirements tracing and it involves filling out a huge spreadsheet with SVN paths

Ciaphas
Nov 20, 2005

> BEWARE, COWARD :ovr:


ExcessBLarg! posted:

Honestly, though, the best option is to have one branch and conditionally-compile platform-specific code. Even with shell scripts, you can usually have a "foo-linux.sh" and "foo-sun.sh" which are called by a master "foo.sh" after determining which OS you're on.

This is probably what we're gonna end up doing really, yeah. Figured I'd explore the alternatives, though, since we're not gonna have to support more than two platforms for more than a year. (I hope. Server hardware purchasing is such a bitch around here like that.)

Lumpy
Apr 26, 2002

La! La! La! Laaaa!



College Slice
Here's quite a git pickle! Every time I commit / push, I seem to create an entirely new history of every single commit to the repo.

Backstory: Created a repo w/ README, pushed to bitbucket. Hooray. Worked on said, made 12 commits, things look lovely, I pushed. All good so far.

Yesterday: Co-Worker clones repo. Makes a change to the .gitignore, pushes. I pull change, make one other change to a different file and push. A git status says I'm 12 commits ahead of remote and that I need to push. Odd, but I'm tired, so I push.

Today: I made one change to a file, commit and push (co-worder has not touched anything in the meantime). For fun, I immediately git status again, and now I'm 25 commits ahead of remote.... :wtf:

code:
LUMPY$ git push https://xxxxxx@bitbucket.org/zzzzz/yyyyyyy.git master
Counting objects: 3, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (3/3), done.
Writing objects: 100% (3/3), 329 bytes | 0 bytes/s, done.
Total 3 (delta 2), reused 0 (delta 0)
To https://xxxxxx@bitbucket.org/zzzzzz/yyyyyyy.git
   810a186..b2318cd  master -> master

LUMPY$ git status
On branch master
Your branch is ahead of 'origin/master' by 25 commits.
  (use "git push" to publish your local commits)
What crazy thing have I done, and how do I un-do it?

Dylan16807
May 12, 2010
Are https://xxxxxx@bitbucket.org/zzzzz/yyyyyyy.git and origin the same place? Why are you passing a full url to push?

Lumpy
Apr 26, 2002

La! La! La! Laaaa!



College Slice

Dylan16807 posted:

Are https://xxxxxx and origin the same place? Why are you passing a full url to push?

Yes they are. No real reason I guess... I just up-arrowed from my initial push and so had the full URL there. Could that be the cause?

Plorkyeran
Mar 22, 2007

To Escape The Shackles Of The Old Forums, We Must Reject The Tribal Negativity He Endorsed
If you push and pull using a URL git won't update any of your remotes even if that remote happens to be for the same place, so if you never actually fetch origin then origin/master will never update.

Lumpy
Apr 26, 2002

La! La! La! Laaaa!



College Slice

Plorkyeran posted:

If you push and pull using a URL git won't update any of your remotes even if that remote happens to be for the same place, so if you never actually fetch origin then origin/master will never update.

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.

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

Lumpy
Apr 26, 2002

La! La! La! Laaaa!



College Slice

necrotic posted:

git fetch origin

Well that was easy. Thanks to you and Plorkyeran!

Harik
Sep 9, 2001

From the hard streets of Moscow
First dog to touch the stars


Plaster Town Cop
I'm trying to keep a protocol definition in-sync between the vastly different projects that access it (embedded, iphone, android and django backend).

What's the preferred way to sync one or two files between multiple repos? Submodule is clunky, is there anything better?

Ralith
Jan 12, 2011

I see a ship in the harbor
I can and shall obey
But if it wasn't for your misfortune
I'd be a heavenly person today
If you can spare 5 minutes to read the documentation, submodules work great these days. The interface has been substantially cleaned up from when they were first introduced.

Slanderer
May 6, 2007
Cross -posting from the general questions thread, since I accidentally posted there instead of here:

Slanderer posted:

We're using SVN here (and I'm running TortoiseSVN on my machine), and I'm trying to figure out how to do something extremely stupid. There's an XML file I need to occasionally commit changes to, except I cannot commit any changes to a specific line in the file (the line identifies the hardware debugger I'm using, which is different than what the rest of the team uses). There is no nice solution to it, since the file is parsed by an embedded development IDE has no concept of local settings. I'm wondering if there is a way to prevent myself from committing changes this single line in the XML file. Would I have to do some nonsense with hook scripts that run before and after a commit that change the line in the file back to the default value and then back to my setting again?

Any thoughts?

HFX
Nov 29, 2004

Slanderer posted:

Cross -posting from the general questions thread, since I accidentally posted there instead of here:


Any thoughts?

I think based on the information you have given me, youbare on the right track with hooks.

Adbot
ADBOT LOVES YOU

Ralith
Jan 12, 2011

I see a ship in the harbor
I can and shall obey
But if it wasn't for your misfortune
I'd be a heavenly person today
Yeah, hooks like you describe sound like a pretty reasonable solution, considering the limitations of your tools. Might be worth complaining to whoever maintains the IDE, just so they know they've got a problem.

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