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
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?

Adbot
ADBOT LOVES YOU

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!

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?

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.

ufarn
May 30, 2009
I botched my git config info on one computer, so my git commits were perceived by GitHub as made by another user (an old one I used to have). As a result, I have another person associated with some of my commits, which annoys me.

I want to do these commits over again, but with a new name, but what's the beast way to do this?

git reset --soft <hash of the last working commit>
git push -f

Followed by redoing the commits?

I have mixed experiences with doing soft resets where the original changes weren't staged, so I want to make sure I get it right.

ufarn
May 30, 2009

Suspicious Dish posted:

Or just use git commit -C=HEAD --amend --reset-author. I believe there's a way to use git filter-branch but I'm not sure.
Is git commit -C=HEAD --amend --reset-author all I type, and the commit author name is changed retroactively?

ufarn
May 30, 2009

Lysidas posted:

There's no good reason to do this one commit at a time; it's a huge waste. Run

code:
git filter-branch --env-filter 'export GIT_AUTHOR_NAME="new user name";
export GIT_AUTHOR_EMAIL="new_email@host.tld"' good_commit..bad_commit
where good_commit is the last commit with the correct authorship, and bad_commit is probably HEAD.
Is this the right way to do it:

code:
git filter-branch --env-filter 'export GIT_AUTHOR_NAME="ufarn";
export GIT_AUTHOR_EMAIL="ufarn@gmail.com"' 758c58bd91ce0d1371c8145402de632045649252..HEAD

ufarn
May 30, 2009

Lysidas posted:

Looks good to me. Now that I think of it, you may also want to set GIT_COMMITTER_NAME and GIT_COMMITTER_EMAIL:

code:
git filter-branch --env-filter 'export GIT_AUTHOR_NAME="ufarn";
export GIT_AUTHOR_EMAIL="ufarn@gmail.com";
export GIT_COMMITTER_NAME="ufarn";
export GIT_COMMITTER_EMAIL="ufarn@gmail.com"' 758c58bd91ce0d1371c8145402de632045649252..HEAD
Cool. Do I do a regular git push -f after this as I would after a git reset, when I need it to propagate to GitHub?

ufarn
May 30, 2009
Looks like something went wrong when I tried to enter the command. I was running git bash on Windows (and not running it as an administrator).

code:
$ git status
# On branch registration
nothing to commit (working directory clean)

$ git filter-branch --env-filter 'export GIT_AUTHOR_NAME="John Appleseed";
> export GIT_AUTHOR_EMAIL="john@appleseed.com";
> export GIT_COMMITTER_NAME="John Appleseed";
> export GIT_COMMITTER_EMAIL="john@appleseed"' 758c58bd91ce0d1
371c8145402de632067f19252..HEAD
Rewrite 23f9d4f018f0216e1c8d1419d2831af349903b00 (6/6)
Ref 'refs/heads/dev' was rewritten
rm: cannot remove `c:/(...)/.git-rewrite/revs': Permission denied
rm: cannot remove directory `c:/(...)/.git-rewrite': Directory not empty

$ git status
# On branch registration
# Your branch and 'origin/registration' have diverged,
# and have 6 and 6 different commit(s) each, respectively.
#
nothing to commit (working directory clean)
Now what? :ohdear:

ufarn
May 30, 2009

Lysidas posted:

Run gitk --all & to view the history in your repository. (I can never get any work done without having gitk open -- it's tremendously useful to see the history that you're adding to).

It looks like git filter-branch succeeded in rewriting the history, but failed to clean up some of its internal state. Try removing the c:/(...)/.git-rewrite directory yourself.
According to gitk --all, my e-mail remains the same. :/

I can remove the folder and all, but it looks like something failed or just wasn't applied.

The affected files seem to have branched out somehow:



Maybe that's just a result of the different e-mail associated. Then again, it appears I have made the same mistake at an earlier point where it didn't branch out.

ufarn
May 30, 2009

Lysidas posted:

Here's a good question: what did you expect to happen when you changed your email address in those commits? Why do you think it looks like something failed or wasn't applied? (Also, there are no "files" that have branched out, those are commits.)

Always keep in mind that you cannot change a commit1. As a consequence, you cannot modify the history in your repository. Your only option is to make new history with the changes you want, and then forget the old commits by removing or reassigning all references to them.

You made new history with filter-branch, and git status indirectly told you that there are still references to the old commits:
code:
# Your branch and 'origin/registration' have diverged,
# and have 6 and 6 different commit(s) each, respectively.
You have 6 new commits with different authorship information, but those are only in your local repository because you haven't git push -f'd them.

However, I'd first redo the filter-branch with an earlier start commit -- the one before the first occurrence of the incorrect email address. You'll need to use the -f option since filter-branch is careful about keeping a backup of your old state, and it won't overwrite the previous backup by default. (This backup is the grey original/refs/heads/registration label in your gitk display.)



_____________________________________
1or any type of Git object: tags, commits, trees, blobs.
Thanks. Assuming things went okay, I have to re-enter the exact same command albeit with a different good_commit value? I just checked, and the value I entered the last time referred to a commit before the first wrongful commit. I can try stepping it one commit back, though.

Is the `-f` option only for the push or for the re-entered command as well?

ufarn
May 30, 2009
Not sure it went as planned. I had forgotten to delete .git-rewrite and grant git bash full permissions. This is what I got:

code:
$ git filter-branch -f --env-filter 'export GIT_AUTHOR_NAME="John Appleseed";
> export GIT_AUTHOR_EMAIL="john@appleseed.com";
> export GIT_COMMITTER_NAME="John Appleseed";
> export GIT_COMMITTER_EMAIL="john@appleseed.com"' 97364f933a42fae
00beb2142510517d91b2168b5..HEAD
Rewrite 4dbf0d0ebb21f6a360f903a256596de067f71c7b (7/7)
WARNING: Ref 'refs/heads/<branch>' is unchanged
rm: cannot remove directory `c:/(...)/.git-rewrite/map': Directory not empty
rm: cannot remove directory `c:/(...)/.git-rewrite': Directory not empty
Then I deleted the folder and used git bash with full permissions:

code:
$ git filter-branch -f --env-filter 'export GIT_AUTHOR_NAME="John Appleseed";
> export GIT_AUTHOR_EMAIL="john@appleseed.com";
> export GIT_COMMITTER_NAME="John Appleseed";
> export GIT_COMMITTER_EMAIL="john@appleseed.com"' 97364f933a42fae
00beb2142510517d91b2168b5..HEAD
Rewrite 4dbf0d0ebb21f6a360f903a256596de067f71c7b (7/7)
WARNING: Ref 'refs/heads/<branch>' is unchanged
And this is what my tree looks like:

ufarn
May 30, 2009
I've made a branch, foo, with a bunch of changes from when I branched out from master a couple of weeks ago, so the difference between the two is likely to be huge.

As a result, a lot of files will be affected, and I want to make sure I am able to scrutinize all the affected files to resolve any conflicts after the two are merged to one.

On Windows or Ubuntu, what is the best way to view an intelligible representation of the changes and affected files, and what other precautions do you recommend, before I pull the trigger?

ufarn
May 30, 2009

enki42 posted:

I think it's totally reasonable to review a branches changes before you merge - we do that with another developer literally every time we pull anything into our mainline branch.

git diff master..branch_name will give you all the commits. If you want something prettier than text output, I'd imagine all of the graphical tools have some sort of diff available. Better yet, if you're on GitHub, you can use pull requests to get a great diff view before merging, and even add comments for things to fix before you pull it into your mainline.
Great tips/tricks!

I did, however, go back to change some things on master, so the pull request on branch_name will be a bit misleading, right? Unlike git diff master..branch_name, I take it this will be a diff between the last master commit, before I branched to branch_name, right?

In other words, if we say that I made the branch at master 1.0 and later updated master to 2.0, git diff master..branch_name will show the difference between:
* master 2.0 and branch_name

and the pull request will show the diff for:
* master 1.0 and branch_name

ufarn fucked around with this message at 04:05 on Mar 5, 2012

ufarn
May 30, 2009

gariig posted:

I liked the Wired article that likened Github to Facebook


It's not that Github is technically superior but that everyone is on Github it has a network affect that makes Git and Github better. I would say for personal or open source software go with Github but for closed source software Bitbucket is a better choice (free for under 5).
They also put the article on GitHub, and I can't see anywhere else where it would get the activity and pull requests it got.

GitHub is probably the biggest darling of the tech industry right now, and it's so popular that it's like a digital CV for people. It makes it so much easier to show people what you've done and can do, and the great design facilitates this even more.

ufarn
May 30, 2009
What does GitHub do when you do a merge pull request with conflicts? Does it help you solve them interactively, solve them by itself or stop you with an error message?

ufarn
May 30, 2009
Okay, I have merged my branch with master and resolved all conflicts in my local repo, but can it really be true that I am 40+ commits ahead of origin, just because my other branch was that many commits ahead of my master branch?

Final question before I press the `git push` trigger. :ohdear:

ufarn
May 30, 2009
GitHub have launched a great interactive online tool to learn git: https://github.com/blog/1183-try-git-in-your-browser.

This is probably the best way to learn people could have wished for.

Dealing with unexpected errors, however, are probably 90% of really learning git.

ufarn fucked around with this message at 23:12 on Jul 4, 2012

ufarn
May 30, 2009
In fact, you can put your git repo inside your Dropbox folder. It works horrendously across Windows/Ubuntu some of the time, but it still works quite well for me.

I'm the kind of person who commits rarely - probably because I'm too much of a scrub to get it working in the first go.

ufarn
May 30, 2009

PiotrLegnica posted:

Committing often is a good habit to develop, even if the code doesn't work at the moment. VCS is there to record changes, after all. You can always edit history before pushing, if broken commits in the log bother you.
Often, yes. If you are in college, committing often is great as evidence against plagiarism allegations.

I'm currently using it for a project that might also go on my resumé, so I'm trying to present a slightly doctored impression of my skills. :v:

But generally, it's definitely the way to go.

ufarn
May 30, 2009
How do I bring the new ahead changes from my master branch to another branch? I assume it's some kind of fetch command?

ufarn
May 30, 2009

Suspicious Dish posted:

What VCS are you using?
git on GitHub.

ufarn
May 30, 2009

Suspicious Dish posted:

So you have two branches, and you want to merge them together? You can do that with a merge or a rebase.
Not a merge. I just want to get the recent commit from my master branch to my dev branch.

ufarn
May 30, 2009
The git shell has started asking me for my username and password instead of my ssh password. Why is this? I tried to erase the .git folder and start over, but that didn't help. It's just this folder/project that doesn't seem to work for some reason.

ufarn
May 30, 2009

Suspicious Dish posted:

Maybe because you checked out with the new fancy smart HTTPS instead of ssh?
Ahh, that's probably it. Thanks. I wonder why the hell the GitHub guide used https. I don't recall that happening before.

ufarn
May 30, 2009
Does someone know Github's shorthand syntax for tables in Markdown? It's something like `::foo: bar" for a single row of two cells, but I can't for the life of me remember how it's done. And the documentation on it is non-existent.

ufarn
May 30, 2009
Has anyone using GitHub ever made a commit with a file that included some sensitive information with merges, issues, and whatnot pointing to it?

I doubt anyone will ever see it, and it's nothing major, but I just wonder if it's even at all possible to purge files and information like that.

Especially if it ever happens with an important password or some something such.

ufarn
May 30, 2009
Wow, that's great. Thanks a bunch.

ufarn
May 30, 2009

Suspicious Dish posted:

Change your password. If you've pushed at all, especially in a popular repo (you said merges and issues point to it) consider it compromised.
It's just my e-mail. No changing that, and no one basically watches nor forks my repo.

ufarn
May 30, 2009
I just ran their commands and got this for people interested:

Sh code:
ufarn$ git filter-branch --index-filter \
'git rm --cached --ignore-unmatch <myfile>' \
--prune-empty --tag-name-filter cat -- --all
Rewrite 123 (444/449)rm '<myfile>'
Rewrite 124 (445/449)rm '<myfile>'
Rewrite 121 (446/449)rm '<myfile>'
Rewrite 431 (447/449)rm '<myfile>'
Rewrite 541 (448/449)rm '<myfile>'
Rewrite 110 (449/449)rm '<myfile>'

Ref 'refs/heads/master' was rewritten
Ref 'refs/remotes/origin/master' was rewritten
Ref 'refs/remotes/origin/gh-pages' was rewritten
WARNING: Ref 'refs/remotes/origin/master' is unchanged
The line escapes were added after the fact to preserve tables here. <myfile> and the xyz hashes have been inserted afterwards, too.

Does the last line just mean that I haven't pushed to my remote master at GitHub (which is true)? Or did something fail?

ufarn
May 30, 2009
Submodule question.

Is there a way to just add the files from a repo, and not the repo files in a folder?

And is there a way to cherry-pick a single or few files from a repo instead of all of them?

ufarn
May 30, 2009
GitHub is pretty great, although the interface takes some getting used to.

The real forté of GitHub is its Issues and Pull Request system, which creates a fantastic workflow, once you get the hang of it. Especially if you know how to use Milestones.

ufarn
May 30, 2009

Sailor_Spoon posted:

I've heard good things about Atlassian's Stash. It's quite a bit cheaper than Github:Enterprise (which is excellent and we use at work).
Atlassian also own BitBucket, so it's bound to be pretty grat.

ufarn
May 30, 2009
I'm playing around with .slugignore, and I'm running into a weird problem: when I used my filter in .gitignore, the files are properly ignored, but when I use them in .slugignore, nothing happens; the slug size and number of compressed files remain the same upon push as before I created the .slugignore file.

.slugignore file here: http://pastebin.com/MnF3b9wt.

This would lead me to think that .slugignore just doesn't work, but applying wildcard extension filters like *.png manages to bring the size and file number down, so it does work on some level; there is just something off.

Folders deprecated/ and avatars/ are not at root level, but deeper down inside FWIW.

ufarn
May 30, 2009
I'm finding it really hard to do some testing for this. I'm doing a billion commits back and forth, but I'm not sure how to test against this locally.

Regardless of what I do, I'm told that 109 static files were copied, but the slug varies in sizes - sometimes even if the .slugignore file is empty.

This stuff drives me crazy.

ufarn
May 30, 2009

Pardot posted:

I probably can't post the direct source code, but looking at it, it treats each line that isn't a comment as a shell glob, an d if the file exists, deletes it. So test your lines as shell globs locally.
How does one go about that?

ufarn
May 30, 2009
I've got a rather annoying conflict that prevents me from saving my work:

quote:

fatal: Reference has invalid format: 'refs/heads/master (laptop's conflicted copy 2013-04-16)'

I use Dropbox to store my work, so some conflict has apparently emerged at some point - presumably when editing a single Markdown file.

There are currently two ref heads, one "master", and one "master (conflict etc.)" file inside .git/.

How do I resolve such a conflict?

ufarn
May 30, 2009
I am trying to make a submodule of a gist inside my GitHub repo, but I keep getting errors.

code:
git clone [email]git@github.com[/email]:user/repo.git

cd repo

git submodule add [url]https://gist.github.com/12345.git	[/url]
How am I supposed to do it?

Not much I can do about the auto-tagging in the example code.

ufarn
May 30, 2009
I think it was due to some weird problem with the root repo: "fatal: You are on a branch yet to be born".

Re-cloning the root repo and adding the submodule subsequently fixed it.

Adbot
ADBOT LOVES YOU

ufarn
May 30, 2009
I get an error when trying to merge branches master and other-branch:

Bash code:
$ git merge other-branch
Auto-merging project/foo.py
Auto-merging project/static/css/style.css
E576: viminfo: Missing '>' in line: fkw7080000gn/T/psql.edit.55378
Press ENTER or type command to continue
From what I understand, my vim is borked, but I don't feel like running the sudo suggestions posted online without some goonput first.

EDIT: This is what .viminfo says under mark history:

code:
# History of marks within files (newest to oldest):

> ~/project/.git/MERGE_MSG
	"	7	6
	^	7	7
	.	7	6
	+	2	17
	+	3	0
	+	7	6
fkw7080000gn/T/psql.edit.55378

# History of marks within files (newest to oldest):

> /private/var/folders/8f/hm_q__wj6sl7pv68v6fkw7080000gn/T/psql.edit.55378
	"	1	0

ufarn fucked around with this message at 14:10 on Mar 1, 2014

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