StirlingCodingClub / studyGroup

Gather together a group to skill-share, co-work, and create community
http://StirlingCodingClub.github.io/studyGroup/
Other
2 stars 1 forks source link

Pushing selection of commits - GitKraken #35

Open mattnuttall00 opened 5 years ago

mattnuttall00 commented 5 years ago

Hi all,

Apologies - this is quite a niche question, and seems like a silly one, but I can't find a solution online.

I use GitKraken for version control, and I have got myself into a situation where I can't push from my local repo (computer) to my remote repo (GitHub). This is because I have been producing lots of large files over the last few days, and committing them as I go, and I foolishly forgot to push regularly. So now I think the changes that I am trying to push constitute too large a chunk of files. When I try and push it times out and I get a message about my AOuth token for Github being invalid. I have received this message before, and it was to do with a push/pull being too large.

Possible solutions are: 1) select a subset of the new commits, and push them a few at a time. I can't seem to find a way to do this...

2) Could I just drag and drop the new files directly into the GitHub repo until the two repos match? This seems messy....

Any other ideas would be welcome!

Thanks Matt

jejoenje commented 5 years ago

Hi Matt

I don't have much (any) experience using GitKraken so I'm not sure if I'd be of much help. Have you tried pushing using the command line interface? It may give you some more informative error messages.

If all else fails, I'm not sure, but would it be possible to work around this by creating a series of new branches, and reverting each back (as per here or here for example) step by step until you get to something you can push? Then you can work back through each branch, committing and pushing at each step, until you get back to your last version? This could be pretty laborious though, so I'd first check what error messages CLI git gives you when trying to push.

Sorry if this isn't much help...

J

bradduthie commented 5 years ago

Hi Matt,

I am not sure how to do this with GitKraken, but you can definitely push commits one by one from the command line. Stackoverflow has a good answer here. Each commit has its own ID, which you can tell git to push specifically. For example, a repository of mine has a commit with the following ID: 18f60772f1fa32d600c26aa0b3ced436fc1eb2e0. If I wanted to push it specifically, then I could do the following:

git push -u origin 18f60772f1fa32d600c26aa0b3ced436fc1eb2e0:master

Normally, when pushing every commit up to the head branch, the command line would just be the following:

git push -u origin master

So to solve your problem with 1, you could look at your git log with the command line:

git log

You will then get something like the following (ideally with better commit messages than my own).

commit 3ca7979659e65be4cb77d094a7111735f99b0a31
Author: Brad Duthie <brad.duthie@gmail.com>
Date:   Mon Oct 28 16:12:48 2019 +0000

    A bit more, need to figure out where the extra variation is coming from

commit 5de27ccef2e92ed8cf33eb699e5743cd492b7875
Author: Brad Duthie <brad.duthie@gmail.com>
Date:   Mon Oct 28 15:40:58 2019 +0000

    Some more progress

Those massive numbers after commit are what you need. Note that commits are listed in reverse order, so if I had not pushed in a while and wanted to push one at a time, then I would do the following:

git push -u origin 5de27ccef2e92ed8cf33eb699e5743cd492b7875:master

Followed by

git push -u origin 3ca7979659e65be4cb77d094a7111735f99b0a31:master

Feel free to stop by the office if you need help doing this with the command line interface. Also, if big files are giving you trouble, and you don't want to track them anymore, it is also possible to remove them from your git history.

mattnuttall00 commented 5 years ago

Many thanks @jejoenje and @bradduthie!

I think the pushing each commit individually via the command line is what I need, as I definitely want to keep tracking those files.

I'll have a go myself, but I don't really use the command line so if it baffles me I may well swing by and beg some help

Cheers!

mattnuttall00 commented 5 years ago

Hi all,

Just in case anyone else runs into this issue, the solution suggested by @bradduthie worked. Details are:

image

Job done

bradduthie commented 5 years ago

Quick -- edit, should be <name of the remote to be pushed to> instead of the repository name. You can find this by typing:

git remote -v

Usually this is origin, but you might have named it something different.