Welcome to the Git quiz!
Here's a quick litmus test for anyone looking to contribute to Hyperswitch or any open source repository in general. This quiz encapsulates basic concepts that you'd need to get started. Haffun!
- In a recent commit someone created a new file, and moved functions from random files into this file (because modularity). Now it seems that there might be a bug in one of these functions, and the dev that created the file doesn't know the underline logic present in the functions, how can you quickly know who authored it?
[a]
git blame
[b]
git blame -C
[c]
git blame -C -C
[d]
git blame -C -C -C
Answer!
git blame -C -C # This is the right git blame -C -C -C # But, this isn't wrong! (why?)
- Which of the following commands are used to go to a different existing branch?
[a]
git branch <branch-name>
[b]
git switch <branch-name>
[c]
git branch -c <branch-name>
[d]
git checkout -b <branch-name>
Answer!
git switch <branch-name>
- Consider, if you have to raise a PR to a external open source repo, what are the steps that you will follow? (Consider the OSS repo is on github, mention the steps that are performed locally as git commands and that performed on github & anything else as simple points)
Answer!
Following are the steps of contributing to OSS repos 1. Find issue and communicate about possible solution. 2. Fork the repository 3. Clone it to your local setup. 4. Configure components mentioned in the `README.md`s 5. `git checkout -b <branch-name>` create a new branch for development 6. complete the development, commit the changes following the guidelines for commits as mentioned in their repository 7. add your personal forks origin, if you cloned before forking. `git remote add my-origin <your repo link>` 8. push to the repository, either `git push origin <branch-name>` or `git push my-origin <branch-name>` 9. raise a PR to their repository, (Optionally, run CI tests on your local fork, and then raise a PR)
- You have made a few changes and added a few new files, turns out you have to start working on something else, so you need to keep everything that you have done aside, how will you do that?
Answer!
`git stash -u`
- You are reading a file in your local git repository, and you wish to know more about a certain function you saw in it, but there is no documentation, how can you get information about it?
Answer!
`git blame /path/to/file` and ask the author about more details
- What’s the difference between
git merge
andgit rebase
?
Answer!
git merge, ands a new commit to your new branch which gets the branch up-to-date with the branch that your are merging. git rebase on the other hand rebases the commits on top of the other branch. The following diagram explains it. U----V----W----X---- (your current branch) / / <--- (the merge) -A----B----C----D----F (branch to be merged) git merge U----V----W (branch after rebase) U----V----W / (branch before rebase) / / -A----B----C----D----F (branch to be merged) git rebase
- Oops, someone accidentally pushed a commit to your main branch and that’s breaking quite a few things, what would you do, if you want to get the main branch stable again?
Answer!
`git revert HEAD`
- You have done some changes to your branch, you want to view those changes before committing them, what would you do to view what new code you have added.
[a]
git log
[b]
git show
[c]
git diff
[d]
git status
Answer!
`git diff`
- You are working on a new feature, while testing you found out that the application isn’t showing any logs. Luckily, a collaborator mentioned she added a commit just to enable logging in her own branch, but it was a long time back and she had added more commits after that, what would you do?
Answer!
`git cherrypick`
- You are getting ready for deploying your project on cloud, but the server configuration file in your branch is amiss, once again a collaborator to the rescue, lets you know that he has a proper config in one of his commit but unfortunately the commit also has other changes. you want to do a dry-run of the config by getting the changes from that single file into your current branch, which git command can accomplish this?
Answer!
`git checkout branc-name:/path/to/file`
- You have added a commit to your branch, the commit message looks something like,
feat(db): add new tabel to customre database
seems like it there are a few spelling mistakes, how can you fix the commit message?
Answer!
`git commit --amend`
- You are maintaining a rust project on GitHub, and someone raised a PR to it with the binaries for the compiled rust project, but those are huge and we don’t need them. What can you do, so that now one in the future is able to commit
/target
directory to the repo?
Answer!
Add the folder in `.gitignore`
- You had cloned your friends repository, and were working on it. You came up with a solid feature and committed it to your local branch, instead of sending the branch to his repository, you want to send it to your own fork of his repository on GitHub, list exactly 2 commands that will which when run in succession will allow this to happen.
Answer!
Do the following 1. Add remote `git remote add my-origin ` 2. Push change `git push my-origin `
- You are working on a branch and want to incorporate the changes made to the main branch. What command do you use to do this?
Answer!
`git pull origin main`
- How will you make sure that your name and email appears on every commit that you make?
Answer!
adding them to `git config` entries will be `user.name` and `user.email`
Embark on an enlightening journey through the intricate world of payments. These blogs are your compass to navigate the complexities of the payment galaxy.
As developers, we create a lot of value through the applications we build. Payments are the means to capture some of that value for ourselves. Surprisingly, the effort to set up a payments stack is often exaggerated. This is what we aim to solve at Hyperswitch by building a free and open payments switch. If you resonate with this vision, you can join the movement to help build an open payments ecosystem!
Learn more about how you can set up your own payments stack in minutes with Hyperswitch
- Want to contribute? Check out some of our good first issues here.
- Try Hyperswitch. Get your API keys here. Happy reading!