Do all the things like ++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatarSign Up
Get a devDuck
Rubber duck debugging has never been so cute! Get your favorite coding language devDuckBuy Now
Search - "git checkout -- -a"
The superpower to perform version control on reality. (Git)
Imagine this universe (the current branch), which is made up of a series of events (commits).
Having this ability to allows us to:
- undo events (git reset/git revert)
- reorder events (git rebase)
- transfer to another universe (git checkout)
- derive a new universe from current universe (git checkout -b)
- delete a universe (git branch -D)
- apply an event from another universe (git cherry-pick)
and my favorite:
- merge universes and their events (git merge)
we have to resolve conflicting events, of course.
What else? ;)8
Just saw a repository with branch name - 👶
bitbucket gives this - git fetch && git checkout 👶 for checking it out,
wondering how would anyone checkout this branch without copy pasting the above line from the web xD10
Commit fast, commit often.
I lost a day's worth of code once, because I wanted to commit all of them in the evening right before I was to go home. Then I mistakenly hit `git checkout .` instead of `git add .`.
Had nothing to do today, so I thought I´ll test the migration of SVN to Git in Gitlab.
Boss sent me a mail today, that when I migrate we need to preserve the history, so I actually have to put some effort in it. *sigh*
Shout-out to the Gitlab documentation at this point.
That´s probably the best doc I´v ever read...
Well so I tried to use svn2git. And well...
Who the fuck thought that this piece of shit software is in any way usable?
If it fails, it just does so without any info why. Even in verbose mode.
And the RAM usage? What the actual fuck?
This whole thing is a complete memory leak!
32Gigs of RAM full in Minutes and the whole system starts to stall!
And then when I thought it finally runs through.
Bam another git checkout error...
Googling for that error then I found something. A version of svn2git made in .Net Core.
Didn´t expect much but I tried it anyways.
And would you look at that!
It ran so smooth and didn´t need that much RAM , I had some doubt it did work correctly.
But it did!
I think I´m gonna pay a coffee or two to some guy over in China now!6
Introduced git in work about 5 months ago, explained to my coworkers how it works, shared links to tutorials, git pro book and everything imaginable.
Almost every day I learn something new ... they keep struggling to checkout a branch or resolve some simple conflict...
I'm just tired of explaining things...
Now I just go and fix every thing and learn a lot :)8
When your team member does a “git checkout .” instead of “git add .” after an intense session of debugging..
Boss: some consultants worked on this feature extending some legacy code
Boss: it's 90% done
Boss: they used FTP. It uses iframes and we fired them when they couldn't get the frontend modules working in sync with the backend.
Me: git checkout -b herewegoagain
git diff-tree --no-commit-id --name-only -r 666w3wl4d
*copy output list of files to sublime text 3; select all lines; add to each:
gitk --follow [filename] > src/.notes/herewegoagain/[filename].diff
Me: It's -10% done. you'll know I'm almost done when I enter the fugue state. You'll find me at this address. Give me this USB stick and a 4 pack of redbull and I'll do the merge.6
You lousy fucking test class of an ass wipe,
TLDR; it fails and it passes all at the same time.
So during a deployment, one of the pre-deployment test classes fails, not something anyone has worked on so figured I run it manually to see what’s going on, but no the shit of a thing passed second time around.
Now because we can’t deploy without 100% of the test classes passing so I have to organise another deployment which it fails again. Fuck this,
Git checkout master
Git merge dev
Git push master -f
Well would you look at that, it works now 😰
-2 mins to weekend, getting ready for a Friday rage push.
Checkout master? Done. Staged everything? Done. Impersonating boss with git credentials? Done.
120 sec to push.
Git: Before you pull you need to commit your changes
*Doesn't even run a git diff to see what changes git was talking about.*
git checkout .
git clean -i
I think the reason why git beginners have a hard time with it is because the api is a bit untuitive.
For example: if you want to "unstage" staged changes, you run git reset, and if you want to "delete" those changes from your working copy, you git checkout those files.
But then, you find out that you can do all of that if you git add . and git reset --hard.
So you're like "huh..."
And then you discover that if you end the resethard with a branch name/commit id then you also make current branch point to the commit or that branch/commit (respectively).
So you're like "huh..."
And also if you add a commit id or branch name to git checkout, you change the current branch to specified/enter detached state with HEAD pointing to that commit (respectively).
Oh and you don't use git branch to create branches, you use git checkout -b because it's a lot shorter.
So here's a rundown: git reset mutates things related to files, but also mutates things related to branches.
git checkout also mutates things related to files and mutates things related to branches too (in a diff way). Also, creates new branches.
I don't think this is intuitive. We users use the same commands for different purposes with just a different flag.
Commands shouldn't mutate different types of things. But don't composite commands (as in, "smart" commands that mutate different things) shoudln't be a flag in an existing command, it should be a single new command of its own.
Maybe if I reread the internals of git now, I'll be able to disgest the dozens of technical terms they throw at you (they are many). And in my mind, the api will cognitively fit to the explanations.
Here's another one that feels weird too.
If you want to make your changes start on top of someone else's commit, you do git rebase.
But git rebase -i can be used for that, and also to delete, modify changes or message of, reorder or combine previous commits of the current branch.
Maybe the reason why several things we do overlap with the same commands is because they internally do similar things, and while not separating those commands might make it less intuitive, it makes them more sensible? i dunno...
disclaimer: I'm not setting this opinion in stone though, and am aware that git was created by one of the most infuential programmers.7
OPEN SOURCE CONTRIBUTION
Original post link:
Start your open source journey.
To Push your personal project to GITHUB.
1. git init
2. git remote add origin [link]
3. git add .
4. git commit -m "commit message"
5. git push origin master
To contribute to someone else project use the following steps:
1. Fork the repo.
2. Clone the project in your local directory using git clone [link]
3. After clone, create a new branch. git branch [branch name]
4. Checkout to new branch created using: git checkout [new branch name]
5. Make changes in Project then 'git add' and 'commit'
6. Push back the changes using git push origin [newbranch name]
7. Open Github web view and click the pull request button and you are done.
Follow Up Post: https://lnkd.in/fEMbTPC
GitHub Link of GIT-CHEATSHEET: https://lnkd.in/fhy4hmu
HD VIDEO: https://lnkd.in/fmq8GTd5
Oh my motherfucking God...
How the fuck can a dumb IDE be so fucking slow? I entered the office at 8:15. And I am still unable to checkout a motherfucking previous version of an android app in git and get Android studio to build it, because the fucking gradle is so damn slow it freezes the GUI. WHAT. THE. FUCK. Android studio get you shit together and maybe, just maybe don't be such a dick!!!
You need 5 min to open that project and another 10 to build it ONLY FOR ME TO REALIZE THAT I HAVE TO REPEAT THAT WHOLE PROCEDURE BECAUSE I NEED A DIFFERENT APP VERSION FROM THE GIT REPO FUCK YOU YOU SHITFACED STUPID COCKSUCKING CUNT, SHIT FUCK ARRRRGH!!!
Edit: now it's 9:35 btw7
I'm the company's git guy. Here's an actual, typical, interaction:
[Coworker] 12:08 PM:
Hi jallman112, good afternoon
[Coworker] 12:08 PM:
I get this error -
[Coworker] 12:08 PM:
git.exe clone --progress -v "[path to local SVN checkout]\repoName" "[path to local git folder]\repoName"
Cloning into '[path to local git folder]\repoName'...
fatal: '[path to local SVN checkout]\repoName' does not appear to be a git repository
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
git did not exit cleanly (exit code 128) (515 ms @ 3/14/2019 12:07:26 PM)
[Me] 1:38 PM:
Looks like [path to local SVN checkout]\repoName is not a git repo1
So we have this project that we are hosting on our testing server for presentation purposes ( already provisioning prod server ).
Our boss was presenting it to investors and my superior committed a bug there and was asking me help to figure out how to fix it (yeah.. he doesn't know how to checkout last commits in git... fml), and I realised the presentation might still be going on... so I asked: isn't boss showing it to investors?
superior: lol, idk maybe.
me: right... ( I proceed to roll back changes ) bye, have a good lunch.
And here I am having lunch considering my life choices.
So, I was doing some basic engineering project at uni with a teammate but we didn't realize that we were working in a detacted head state in git (due to poor set up of the working environment on his part).
After a 3,5 hours of work, we need to push to the repo and we get an error.
I take control to try to understand what was going on, and in doing so, I (mistakenly?) check out to another branch.
Git garbage collector kicks in and we can't checkout to the previous branch anymore (where all the work was made).
My friend panics and calls the professor, who explains to us how we lost everything and there is "a 100% no hope of recovering our work".
Felt like poop. But wasn't satisfied. I had read somewhere that you don't lose stuff so easily on git. Went home.
After five minutes I was able to recover everything through git reflog feature.
Moral #1: professors should know about the existence of reflog
Moral #2: please use git plug-in in your bash /zsh. Please.1
Hi guys what is the meaning of double back slash in my Git folder? It is not removed when I do a "git clean -fd". This is the first time I encountered something like this.
$ git status
On branch master
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git checkout -- <file>..." to discard changes in working directory)
(use "git add <file>..." to include in what will be committed)
no changes added to commit (use "git add" and/or "git commit -a")9
Every bloody time I work on a ticket and am about to be done... "git commit -av" Looking at the branch... Bloody hell, I am working again in master... Aborting commit. Checkout -b to a new branch... Committing... Going back to master... Merging my new branch into master... This exercise seems so pointless.
thanks to @olback i learned about localStorage today. excited me started to implement this. after half of the refactoring was done i had the brilliant idea to test it with the intended ie11 after everything was fine with firefox. only to find out localStorage is not supported for local sites.
This was sadly recent. I have git checkout aliased to ‘gco’.
I was on a dev branch with a load of uncommitted changes, and I accidentally ran ‘gco ..’ instead of ‘cd ..’ (I use them both quite often)
That was one of my more frantic google searches.....
Thankfully I was able to get all my changes back, but only thanks to IntelliJ’s local history feature allowing me to revert each file reload from disk.
Spent half a day working on some code to add some functionality. Ran into some binary assumptions and found workarounds. Got everything implemented and close to start testing things. Not a lot of code, but a lot of places that needed careful attention to detail. Started looking at the final code needed for initializing things. Found that all the code I wrote would not be needed if I just initialize some things differently. Realized I don't need all this code. The code is literally redundant.
git checkout <changed files>
Okay, now I understand the code better. I am ahead because I am not maintaining code I don't need. Half a day of reading the code helps me understand everything that is there.
Life is good. 😀
If anyone is interested in having a git command to auto-checkout-pull-checkout-rebase, I made a "git magic" command which will do exactly that!
Was exhausted after coding for a full day, was going to commit all the work at the end of the day. Then my brain snapped: wanted to hit `git add .`, hit `git checkout .` instead.
Lesson learned (the hard way): "commit fast, and commit often"1
TFW you realize that using git to track your dotfiles was a really good idea!
echo "Oh shit, I overwrote my ssh keys"
`git checkout .ssh/id_rsa`
`git checkout .ssh/id_rsa.pub`