🐙
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?

Last updated 1 year ago

Was this helpful?

Scenario

Pushing Local Changes to a Remote Repository.

Ensure Local Repository is Up-to-Date:

Before pushing changes to a remote repository, it's crucial to ensure that your local repository is up-to-date with the latest changes from the remote repository. This prevents potential conflicts and ensures a smooth integration of your changes.

To update your local repository, execute the following command:

The git pull command fetches the latest changes from the remote repository and automatically merges them with your local branch.

  • Commit Your Changes: After verifying that your local repository is up-to-date, commit your changes using the following command:

It is important to provide a descriptive commit message that explains the purpose of your changes.

  • Pushing Changes to the Remote Repository: To push your committed changes to the remote repository, utilize the git push command:

The git push command transmits your local commits to the remote repository, making them accessible to other collaborators.

Scenario: Fetching and Merging Remote Changes

  • Fetch Remote Changes: To obtain the latest changes from the remote repository without automatically merging them with your local branch, execute the following command:

The git fetch command retrieves the remote changes and stores them in a separate branch in your local repository.

  • Review Remote Changes: After fetching the remote changes, it is important to review them before integrating them with your local branch. You can inspect the changes using various Git commands, such as git log, git diff, or Git GUI tools, depending on your preferred workflow.

  • Merge Remote Changes: To merge the fetched remote changes with your local branch, use the following command:

This command incorporates the changes from the specified remote branch into your local branch, combining the histories and resolving any conflicts that may arise.

Alternatively, you can use the git pull command, which combines the git fetch and git merge steps in a single operation:

However, using git pull directly may result in unexpected conflicts if you have uncommitted changes in your local branch. It is generally recommended to commit or stash your local changes before executing git pull.

git pull origin <branch-name>
git commit -m "Your commit message"
git push origin <branch-name>
git fetch origin
git merge origin/<branch-name>
git pull origin <branch-name>
  1. 🤝Working with Remote Repositories
  2. Collaborating with Git - Practice Scenarios

Pushing and Pulling Changes

PreviousCloning a Remote RepositoryNextCollaborative Workflow with Forking and Pull Requests