Common FAQs About Git and GitHub

Git and GitHub are essential tools for modern software developers, enabling efficient version control and collaboration on code projects. Here are some of the most frequently asked questions about these tools:

1. What is Git?

Git is a free and open source distributed version control system designed to handle projects of any size with speed and efficiency.

2. What is GitHub?

GitHub is a source code hosting platform that uses Git for version control. It provides a web interface for collaborating on software projects.

3. How does Git differ from other version control systems?

Git is distributed, which means that each developer has a complete copy of the repository, including its history. This allows for fast and versatile operations regardless of network access.

4. What is a repository in Git?

A repository is a collection of a project's files and their revision history. In Git, this is where the history of your changes is stored.

5. How can I install Git?

You can download Git from the official website (git-scm.com) and follow the specific instructions for your operating system.

6. What are branches in Git?

Branches are parallel versions of a repository, created to develop features in isolation without affecting the main line of development (generally called "master" or "main").

7. How do I create a new branch?

Use the command git branch branchname to create a new branch and git checkout branchname to switch to it.

8. What is a commit in Git?

A commit is a set of changes that is recorded in the repository's history. Each commit has a unique identifier called a hash.

9. How do I make a commit?

After adding your changes to the staging area with git add, you can commit with git commit -m "commit message".

10. What is a pull request on GitHub?

A pull request is a request for changes from one branch to be merged into another branch, usually in the same repository on GitHub.

11. How can I clone a GitHub repository?

Use the git clone repository_url command to create a local copy of the repository on your machine.

12. What is the staging area in Git?

The staging area is a layer between your working directory and the repository history, where you can stage and review your changes before committing.

13. How do I undo a commit?

To undo a commit and keep the changes in your working directory, use git reset --soft HEAD~1. To discard changes completely, use git reset --hard HEAD~1.

14. How can I see the commit history?

Use git log to see commit history. You can add options to format or filter the output.

15. What is a merge in Git?

Merge is the process of combining changes from two branches. If there are no conflicts, Git will create a new merge commit.

16. How do I resolve merge conflicts?

When Git fails to merge automatically, it marks conflicting files. You must manually edit these files to resolve the conflicts and then make a new commit.

17. What is a rebase in Git?

Rebase is an alternative to merge that realigns one branch with another, rewriting the commit history to create a cleaner development pipeline.

18. How can I contribute to a project on GitHub?

Fork the repository, clone it, make your changes, and submit a pull request to the original repository.

19. What are issues on GitHub?

Issues are a way to track improvements, tasks, or bugs for a project on GitHub. They can be commented and updated by collaborators.

20. What is a fork on GitHub?

A fork is a personal copy of another user's repository on GitHub. It allows you to try out changes without affecting the original repository.

21. How can I keep my fork up to date with the original repository?

You can set up a remote to the original repository and fetch the changes followed by a merge or rebase on your fork.

22. What is a .gitignore file?

The .gitignore file specifies intentionally untracked files and directories for Git to ignore.

23. What is Git Flow?

Git Flow is a branching model that defines a rigid structure of branches for projects, optimizing the delivery of features and releases.

24. How can I view the changesrations before making a commit?

Use git diff to see the differences between your working directory and the staging area, or between the staging area and the last commit.

25. What is an alias in Git?

An alias is a shortcut you can configure for longer Git commands, allowing you to use shorter, custom commands.

26. How can I revert a file to a previous state?

Use git checkout followed by the commit hash and file name to revert to a previous version of that file.

27. What is a remote in Git?

A remote is a reference to a remote repository. The default remote is usually called "origin", which points to the repository you cloned from.

28. How can I change the message of the last commit?

If you haven't yet pushed the commit to a remote repository, you can use git commit --amend -m "New message" to change the message.

29. What is a squash commit?

Squash commit is the process of combining multiple commits into a single commit, usually done during a rebase or before a merge.

30. How can I create tags in Git?

Tags are used to mark specific points in the repository's history, such as releases. Use git tag tag_name to create a new tag.

31. What is a README file on GitHub?

The README file is usually the first thing someone sees in a repository on GitHub. It should provide information about the project, how to install, use and contribute.

32. How can I add an SSH key to GitHub?

In your GitHub account, go to "Settings" > "SSH and GPG keys" and click "New SSH key" to add your SSH public key.

33. What is an organization on GitHub?

Organizations are groups on GitHub that allow you to collaborate on multiple projects with other members, setting permissions and managing multiple repositories.

34. How can I secure a branch on GitHub?

On GitHub, you can protect branches to prevent them from being deleted or force certain conditions before allowing merges, such as code reviews and successful status checks.

35. What are GitHub Actions?

GitHub Actions is a CI/CD platform integrated with GitHub that allows you to automate your software workflows directly from your repositories.

36. How can I delete a local or remote branch?

To delete a local branch, use git branch -d branch_name. To delete a remote branch, use git push origin --delete branch_name.

37. What is a Git hook?

Git hooks are scripts that you can configure to be triggered by specific events in the Git lifecycle, such as before a commit or push.

38. How can I view remote branches?

Use git branch -r to list all remote branches that your local repository knows about.

39. What is a Git configuration file?

The Git configuration file, often called .gitconfig, stores user-level or repository-level settings for Git's behavior.

40. How can I set a default editor for Git?

Use git config --global core.editor "editor_name" to set a default editor for commits and other Git messages.

41. What is a GitHub Gist?

GitHub Gist is a GitHub service for sharing code snippets or plain text. Each Gist is a Git repository, which allows for easy versioning and collaboration.

42. How can I see who made changes to a file?

Use git blame filename to show who made the last changes to each line of a file, along with the corresponding commit.

43. What is GitHub Pages?

GitHub Pages is a free hosting service for web pages directly from a repository on GitHub, ideal for hosting personal projects, documentation or blogs.

44. How can I cherry-pick a commit?

Cherry-pick is a Git command that allows you to apply changes from a specific commit from one branch to another. Use git cherry-pick hash_do_commit.

45. What is a pull request draft?

A draft pull request is a pull request that is not ready for review or merge. It allows you to work on your code and get feedback without the risk of someone merging your changes prematurely.

46. How can I add collaborators to a repository on GitHub?

In the GitHub repository, go to "Settings" > "Collaborators" and add the GitHub usernames of the people you want to invite to collaborate.

47. What is a GitHub Star?

A GitHub Star is similar to a "like" on social networks

Now answer the exercise about the content:

What is the fundamental difference between Git and GitHub as described in the common FAQs?

You are right! Congratulations, now go to the next page

You missed! Try again.

Article image Collaborative workflows: Rebase vs. Merge Workflows

Next page of the Free Ebook:

62Collaborative workflows: Rebase vs. Merge Workflows

4 minutes

Obtenez votre certificat pour ce cours gratuitement ! en téléchargeant lapplication Cursa et en lisant lebook qui sy trouve. Disponible sur Google Play ou App Store !

Get it on Google Play Get it on App Store

+ 6.5 million
students

Free and Valid
Certificate with QR Code

48 thousand free
exercises

4.8/5 rating in
app stores

Free courses in
video, audio and text