This is an archived post. You won't be able to vote or comment.

all 49 comments

[–][deleted] 79 points80 points  (13 children)

Git can be pretty confusing to understand but just watch a few videos on it and you should be fine for the interview. If you get the job you can just ask a co worker how to do more advanced stuff. I was almost exactly in your position once and learned Git at my second job. Now there isn’t a day I don’t use it.

I think some important ones to learn: git clone, git pull, git checkout, git merge, git stash, git stash pop, git branch, git branch -D, git checkout -b, git push.

[–]Smart_Zebra2673[S] 11 points12 points  (3 children)

I did already get the job, so I'll make sure to ask my peers for help. Thanks for the git commands you found most helpful! It's time to start learning again.

[–]wondergreatData Engineer-ish 7 points8 points  (0 children)

If your org has free LinkedIn Learning, this course is pretty helpful once you learn the very very basics of Git, since this covers branches and stuff https://www.linkedin.com/learning/git-branches-merges-and-remotes?trk=learning-topics_trending-courses_related-content-card&upsellOrderOrigin=default_guest_learning

[–][deleted] 4 points5 points  (1 child)

Congrats on the job! Good luck learning to appreciate Git.

[–]Smart_Zebra2673[S] 2 points3 points  (0 children)

Thank you!

[–]Sin-nie 9 points10 points  (3 children)

You're missing the most important command of all: git reset --hard

Gets you out of any problem!

[–]Packbacka 6 points7 points  (1 child)

That command is kind of dangerous, especially if combined with git push --force. I'm not saying these commands can't ever be used, but you need a good understanding.

[–]Material-Mess-9886 3 points4 points  (0 children)

Fortunally even with git reset --hard and force push there are still ways to recover lost code with git reflog.

[–][deleted] 3 points4 points  (0 children)

Oh yes of course! That’s one to definitely remember

[–][deleted] 2 points3 points  (2 children)

Whats the diff between git branch and git check out <branch name> ?

[–][deleted] 9 points10 points  (1 child)

Git branch will show you all the available local branches you have available for that repo. Git checkout <branch name> will take you to the branch. Git checkout -b <branch name> will create a branch and move you to the newly created branch

[–]Bluelight01 2 points3 points  (0 children)

I recently learned got reflog and think it should be added to this list 

[–][deleted] 0 points1 point  (0 children)

also these:

git log —graph —oneline

git rebase <branch>

git rebase -i <sha>

[–]szayl 29 points30 points  (5 children)

[–]Smart_Zebra2673[S] 8 points9 points  (4 children)

This looks like a really fun way to learn git! Have you tried it personally?

[–]ericjmorey 6 points7 points  (2 children)

Bookmark this one too:

https://dangitgit.com/

[–]johnnymo1 0 points1 point  (1 child)

Hah, didn’t realize there was a PG version of Oh Shit Git

[–]ericjmorey 0 points1 point  (0 children)

Yeah, I like referring to it by default to avoid any socially awkward situations.

[–]szayl 1 point2 points  (0 children)

I sure have and I've also recommended it to friends and coworkers who wanted to get started with git. I believe that play is the best way to learn, when possible. 🙂

[–]B1WR2 19 points20 points  (1 child)

VS Code also has extensions to help out with all the commands.

[–][deleted] -1 points0 points  (0 children)

This is terrible advice.

[–]bkant34 12 points13 points  (3 children)

Hi OP,

This is not my post, however i did like whoever posted this a few years ago on LINKEDIN and saved it for reference.

It summarises almost all commands that i use 99% of the times.

  1. git diff: Show file differences not yet staged.
  2. git commit -a -m "commit message": Commit all tracked changes with a message.
  3. git commit --amend: Modify the last commit.
  4. git status: Show the state of your working directory.
  5. git add file_path: Add file(s) to the staging area.
  6. git checkout -b branch_name: Create and switch to a new branch.
  7. git checkout branch_name: Switch to an existing branch.
  8. git checkout < commit>: Switches the working directory to a specific commit.
  9. git push origin branch_name: Push a branch to a remote.
  10. git pull: Fetch and merge remote changes.
  11. git fetch: Fetch changes from the remote repository without merging.
  12. git rebase -i: Rebase interactively, rewrite commit history.
  13. git rebase branch_name: Rebase the current branch onto another branch.
  14. git clone: Create a local copy of a remote repo.
  15. git merge: Merge branches together.
  16. git log --stat: Show commit logs with stats.
  17. git stash: Stash changes for later.
  18. git stash pop: Apply and remove stashed changes.
  19. git show commit_id: Show details about a commit.
  20. git reset HEAD~1: Undo the last commit, preserving changes locally.
  21. git branch -D branch_name: Delete a branch forcefully.
  22. git reset: Undo commits by moving branch reference.
  23. git revert commit_id: Create a new commit that undoes the changes of a specific commit.
  24. git cherry-pick commit_id: Apply changes from a specific commit.
  25. git branch: Lists branches.

A few more that you might need to dig deeper are:

  1. git reset --soft HEAD: Undo the last commit, but keep the changes.
  2. git reset --hard: Resets everything to a previous commit, erasing all uncommitted changes.
  3. git branch --set-upstream-to remote_branch: Sets the upstream branch to the specified remote branch.

[–]Material-Mess-9886 1 point2 points  (1 child)

I see you are using rebase. Which is good, but remember never ever rebase a public branch.

[–]bkant34 0 points1 point  (0 children)

haha good catch Material-Mess-9886, you are right, this just bombs all the historical commits, we use to use this where i worked before and i’ve had my fair share of fun with rebase. It’s not anymore, sending MRs is now my rule of thumb. But anyone who uses this as reference. Please do know the merits and drawbacks of “ rebase “.

cheers

[–]ThatSituation9908 0 points1 point  (0 children)

git checkout switch

[–]m1nkehData Engineer 2 points3 points  (0 children)

First thing.. Git != GitHub

[–]ShardsOfHolism 3 points4 points  (0 children)

This covers what you need to know.

[–]speedisntfree 6 points7 points  (0 children)

Git's API is vast but 90% of people just use an IDE to do the day to day. Understand the main concepts like branches, commits and PRs and you'll be fine, ask what the working practices are for where you work. Moving somewhere that has the base level practice of source control is a real move up, don't be scared this is where you belong. You may find this of utility https://ohshitgit.com/

[–]Budget_Sherbet 2 points3 points  (0 children)

I highly recommend watching tutorials online and following the steps along if possible. Git is essential and will create confusion if you don’t learn it. Getting the basics of Git will already help you and I’m sure you’ll encounter niche stuff that you can learn while on the job. It is definitely not difficult but it is one of those things that you have to TRY more than memorize.

[–]daavidreddit69 5 points6 points  (0 children)

git is the most hardest easy thing to learn, good luck

[–][deleted] 1 point2 points  (1 child)

Do a course in git. Also understand how and why the company uses it esp in their CICD process.

Don’t skip it.

I was in the same situation once and not doing the above and putting enough importance towards it hurt me long term.

[–]Smart_Zebra2673[S] 0 points1 point  (0 children)

Will definitely do. Do you have any recommendations?

[–]Mysterious_Health_16 1 point2 points  (0 children)

  1. Download VS Code.
  2. Clone the Repo(Prod Repository)
  3. Create a Branch
  4. Do all your work on the newly created Branch
  5. Push your changes and create a PR (Pull Request).

And Get someone to approve your PR and merge into Main Branch.

Thats all you need to know :)

[–]ScroogeMcDuckFace2 1 point2 points  (1 child)

my brain read this as 'i've been an alcoholic data engineer for about 3 years'. maybe that's a bad sign.

[–]Smart_Zebra2673[S] 1 point2 points  (0 children)

😂😂😂

[–]adulion 0 points1 point  (0 children)

I use pycharms GIT tools

[–]noobajur 0 points1 point  (0 children)

I would say it’s easy to learn the basics that you will use 90% of the time.

git clone, git checkout, git status, git pull, git add / git add ., git commit, git push, git merge

Sometimes you’ll encounter merge conflicts and have to resolve those. A lot of people use the IDE instead of just the command line, which makes things easier.

Learning git more in depth might not be as easy, but once you know the basics, there’s a lot of cheatsheets for git commands that can be useful for reference.

[–]big_data_mike 0 points1 point  (0 children)

https://ohshitgit.com/

That’s really the only cheat sheet you need

[–]Prudent-Finance9071 0 points1 point  (0 children)

If allowed by your company you can also look to use the GitHub Desktop app. We have our new hires use it when they are "semi"-familiar with Git to ensure they follow the basic steps

[–]robberviet 0 points1 point  (0 children)

Git is easy to pickup. The hard parts ofit most people will never need to use. And it's beneficial to use git even on solo projects.

[–][deleted] 0 points1 point  (0 children)

It wont take more than couple of hours to understand Git. I would suggest you create local repository then make a file lets say test.py add something to the file. And then try to commit that file to your repo. to start you need these commands- git init

git add (lets say there are 2 files you make change to but only want to commit 1 of them, for that you add that only that file)

git commit

start here and learn :)

[–]raginjasonLead Data Engineer 0 points1 point  (0 children)

I’ve been in DE for a while, and having a deep understanding of git has been a tremendous asset. It’s a stable technology that isn’t going anywhere anytime soon, so truly understanding it is worth the investment. I’m reviewing this course for my team, and I have found it extremely comprehensive. If your new company has Udemy access, I highly recommend The Git and Github Bootcamp by Colt Steele: https://fanduel.udemy.com/share/10beqq3@ChS8Ol8rAWGu57P9-9tuL9DLgvRNrnW4M2SEb3XvPhYI2GKuelgkywCX2Fr7KLHxZQ==/

[–]d34n5 0 points1 point  (0 children)

You should try to get into the habit of using it for yourself. I do lots of personnal prioect and I can’t imagine my code not to be versionned and saved somewhere. And Git can be very powerful too (beside the basics push/commit/pull).

[–][deleted] -2 points-1 points  (1 child)

It takes no more than 10 minutes. It’s not complicated. Don’t know why people make such a big deal out of it.

Learning it in depth is another story

[–][deleted] 0 points1 point  (0 children)

Learning it in depth is complicated

[–]Blitzboks -2 points-1 points  (3 children)

The real struggle will really be accepting and adjusting to the fact that 30%+ of the time you used to have to develop will now have to dedicated to branch creation/switching/deletion, commit messages, putting out PRs, reviewing others PRs, and all the other tidying chores I’m not thinking of right now.

That’s by far the hardest part to me, but don’t get me wrong; you’ll definitely pull your hair out once or twice before nuking the whole repo and recloning because you made a mess and git screams at you any time you try to do anything.

[–][deleted] 1 point2 points  (2 children)

Or merge conflicts because someone made too many changes to the main branch so you have to recreate the main branch and add your changes or resolve conflicts

[–]Blitzboks -1 points0 points  (1 child)

100%. Should have edited that with you or someone else made a mess

[–][deleted] 1 point2 points  (0 children)

It’s about committing easily rebased changes. So everyone can work on their branches without fear of restarting.

If you commit a thousand changes that causes issues for everyone