🐙
Git Developer Guide
About
  • Overview
  • Scope of this book
  • Table of Content
  • 🐢Introduction to Version Control
    • What is Version Control?
    • Overview of git and it's benefits
    • Setting up Git on Different Platforms
  • 🍼Git Fundamentals
    • Initialising a new Git repository
    • Understanding the Git Workflow
    • Committing Changes and Writing Good Commit Messages
    • Viewing and Navigating Commit History
    • Git Basics - Practice Scenarios
      • Initialising a Git Repository
      • Committing Changes
      • Exploring Commit History
      • Amending and Undoing Commits
  • 🦕Working With Git
    • What is Git Branch?
    • Creating and Switching Between Branches
    • Merging Branches and Resolving Conflicts
    • Best Practices for Branch Management
    • Git Workflows
    • Git Log
    • Git Stash
    • Working with Git - Practice Scenarios
      • Creating and Switching Between Branches
      • Merging Branches and Resolving Conflicts
      • Branching Strategies in a Team Project
      • Rolling Back to a Previous Version
      • Experimenting with Feature Branches
      • Working with Stash
  • 🤝Working with Remote Repositories
    • Cloning a Repository from Remote
    • Pushing and Pulling Changes to and from Remote Repositories
    • Collaborative Workflows - Forking, Branching, and Pull Requests
    • Resolving Conflicts in a Collaborative Environment
    • Collaborating with Git - Practice Scenarios
      • Cloning a Remote Repository
      • Pushing and Pulling Changes
      • Collaborative Workflow with Forking and Pull Requests
      • Resolving Conflicts in a Pull Request
  • 🏆Advanced Git Features
    • Aliases and Custom Configurations
    • Working with Tags and Releases
    • Rewriting Commit History with Interactive Rebase
    • Utilising Git Hooks for Automation
    • Advanced Git Features - Practice Scenarios
      • Creating Custom Git Aliases
      • Working with Tags and Releases
      • Rewriting Commit History with Interactive Rebase
      • Using Git Hooks for Automated Testing
  • 😎Git in Real-World
    • Managing a Project with Multiple Contributors
    • Integrating Git with Continuous Integration, Continuous Deployment (CI, CD)
    • Versioning Assets with Git LFS (Large File Storage)
    • Deploying a Web Application using Git
    • Git In Real World - Practice Scenarios
      • Managing a Project with Multiple Contributors
      • Integrating Git with CICD Pipelines
      • Versioning Assets with Git LFS
      • Deploying a Web Application using Git
  • Git Troubleshooting
    • Common Mistakes and Pitfalls When Using Git
    • Undoing Changes with Git - Reverting and Resetting
    • Recovering Lost Commits or Branches
    • Dealing with Repository Corruption or Other Issues
  • Git Best Practices and Tips
    • Creating efficient git workflows: writing clean code for faster reviews
    • The importance of clean code in collaborative development
    • Significance of consistent naming conventions & coding Standards
    • Good code documentation for better git workflows
    • Writing meaningful git commit messages
    • Atomic commits in git & it's benefits for software teams
    • Structuring code & managing dependencies for better git workflows
    • Git branching strategies for software teams
  • Conclusion & Next Steps
    • Recap of Key Concepts and Commands
    • Further Resources for Expanding Git Knowledge
    • Encouragement and Tips for Continued Learning and Practice
  • License Considerations
Powered by GitBook
On this page

Was this helpful?

  1. Working with Remote Repositories
  2. Collaborating with Git - Practice Scenarios

Cloning a Remote Repository

Scenario

You're working a new project with a team, and you have been added to the project team on github. Now you have to clone the project to your local machine. Here's how to go about this.

Step 1: Choosing the Cloning Method

To clone a remote repository, you have two primary options: HTTPS and SSH. The choice depends on factors such as the repository's accessibility and your preferred authentication method.

Cloning with HTTPS

  • HTTPS cloning is convenient when you want to quickly clone a repository without setting up SSH keys.

  • To clone with HTTPS, open your terminal and navigate to the directory where you want to clone the repository.

  • Run the following command, replacing repository-url with the URL of the remote repository:

git clone repository-url

Cloning with SSH

  • SSH cloning is ideal if you have set up SSH keys and want to authenticate using them.

  • To clone with SSH, open your terminal and navigate to the desired directory.

  • Run the following command, replacing repository-url with the URL of the remote repository:

git clone git@github.com:user/repository-url

Step 2: Setting Up the Remote Origin

After successfully cloning the repository, you can set up the remote origin to simplify future interactions with the remote repository.

Change to the Repository's Directory

  • In your terminal, navigate to the cloned repository's directory:

cd repository-directory

Add Remote Origin

  • To associate the cloned repository with the remote origin, run the following command:

git remote add origin repository-url

Verify Remote Origin

  • To verify that the remote origin is correctly set up, execute:

git remote -v
  • You should see the repository's URL displayed as the remote origin.

Step 3: Fetching the Latest Changes

To keep your local repository up to date with the latest changes from the remote repository, you need to fetch the changes periodically.

Fetching Changes

  • To fetch the latest changes, use the following command:

git fetch

Checking for New Branches

  • To check for any new branches added to the remote repository, run:

git branch -r
  • This command lists all the remote branches, and any new branches will be displayed here.

Pulling Changes

  • To incorporate the fetched changes into your local branch, execute:

git pull
  • This command merges the fetched changes into your current branch, ensuring your local repository is up to date.

PreviousCollaborating with Git - Practice ScenariosNextPushing and Pulling Changes

Last updated 1 year ago

Was this helpful?

🤝