Unformatted text preview:

Git and GitHub Tutorial The Ultimate Guide to VC Branching Merging Pull Creating a New Repository Git as a Version Control System Request Part 2 Git is a distributed version control system that allows multiple people to work on a project at the same time Git tracks changes to files and allows you to revert back to previous versions of a project Importance of Username and Global Name It s important to set a username and global name for Git to keep track of who is making changes to the repository This information is used to give credit to the person who made the change and to resolve any conflicts that may arise Untracked vs Untracked Folders Untracked files are new files that Git is not currently tracking Untracked folders are folders that contain untracked files Local and Remote Repositories A local repository is a copy of the project that is stored on your computer A remote repository is a copy of the project that is stored on a server such as GitHub Visual Studio Code for Git Operations Visual Studio Code is a code editor that has built in support for Git This allows you to perform Git operations such as committing changes and pushing to a remote repository directly from the editor Creating a New Repository 1 Open Visual Studio Code 2 Click on the Source Control icon in the Activity Bar on the side of the window new repository it 3 Click on the button in the Source Control panel to create a 4 Enter a name for the repository and select a location to save 5 Click on the Initialize repository button 6 You can now start adding files to your new repository Handling Conflicts and Resolving Merge Issues Conflicts can occur when two people make changes to the same lines of code in a file When this happens Git will give an error and you will need to manually resolve the conflict by choosing which changes to keep Once the conflict is resolved you can commit the changes and push them to the remote repository Untracked vs Untracked Folders In Git the term untracked refers to files or folders that are not being tracked or monitored by Git There are two types of untracked items untracked files and untracked folders Untracked files are files that exist in the working directory but are not being tracked by Git These files will not be included in the next commit unless they are explicitly added using the git add command Untracked folders are folders that exist in the working directory but do not contain any tracked files Git will not track or monitor the contents of these folders unless a file within the folder is explicitly added using the git add command To permanently ignore untracked files and folders you can create a gitignore file in the root directory of your repository The gitignore file specifies a list of files and folders that Git should ignore and not track It is important to regularly check for and manage untracked files and folders in your repository to ensure that your commit history is accurate and that you are not inadvertently committing sensitive or unnecessary files Local and Remote Repositories Git is a distributed version control system which means that local repositories are created on individual machines while remote repositories are hosted on a server or cloud based service Local Repositories Working Directory Contains the current state of the project including all files and folders This is the place where you modify your code and files Staging Area Index A middle ground between the working directory and the local repository Here you can select which changes you want to commit to the local repository Local Repository git folder Maintains a full version history of your project and allows you to track changes maintain branches and make commits Remote Repositories Centralized Repository A single location where all team members can share and access the latest code and files Remote Branches Remote repositories can have multiple branches allowing team members to work on separate features or bug fixes concurrently Pull Requests A mechanism to request changes to the central repository often used for code reviews testing and quality assurance Handling Conflicts and Resolving Merge Issues Git is a powerful version control system that allows multiple developers to work on the same codebase simultaneously However with multiple people working on the same code conflicts can arise When this happens it s important to know how to handle these conflicts and resolve merge issues Importance of Handling Conflicts Conflicts can occur when two or more developers modify the same lines of code in a file or when a file is deleted in one branch but modified in another If these conflicts are not handled properly it can lead to lost changes broken code and delayed dev elopment Understanding Merge Issues A merge issue occurs when Git is unable to automatically merge two branches due to conflicting changes In this case Git will highlight the conflicting changes and require the developer to manually resolve the conflict Resolving Conflicts in Visual Studio Code Visual Studio Code VS Code can be used to resolve conflicts in a Git repository Here are the steps to resolve conflicts in VS Code 1 Open the repository in VS Code 2 Open the Git view by clicking on the Source Control tab on the left side of the window 3 Click on the conflicted branch in the Branch section 4 Click on the file with the conflict in the Changes section 5 In the editor Git will highlight the conflicting changes with and markers 6 Decide which changes to keep and which to discard 7 Delete the markers and save the file 8 Commit the changes to the repository Best Practices for Handling Conflicts Here are some best practices for handling conflicts and resolving merge issues in Git Communicate with other developers to avoid conflicting changes Pull changes from the remote repository frequently Use a Git merge tool such as VS Code to resolve conflicts Test the code after resolving conflicts to ensure it still works as expected Document the changes made during conflict resolution to improve transparency Conclusion Handling conflicts and resolving merge issues is a critical part of working with Git By understanding the importance of handling conflicts and following best practices developers can work efficiently and collaboratively even on large and complex project s


View Full Document

Anna CS 3291 - Git and GitHub Tutorial

Download Git and GitHub Tutorial
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Git and GitHub Tutorial and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Git and GitHub Tutorial and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?