đź’»
How to Use Project Development Tools in a Remote C
  • How to Use Project Development Tools in a Remote Coding Team
  • Trello
    • Introduction to Trello
    • How to use Trello
      • What is Trello?
      • Starting up a Trello Board
      • Lists
      • Cards
  • Visual Studio Code
    • Introduction to Live Share in Visual Studio Code
    • How to use Live Share
      • How to Install
      • How to Use
      • Examples of Use Cases
  • Git & Github - Basics
    • Introduction to Git & GitHub
    • How To Use Git
      • Setting up Git
      • Creating GitHub Repositories
      • Managing Repository Access
      • Syncing with a Local Workspace
  • How to Manage a Codebase with Git
    • Introduction to Branching
    • How To Use Branches
      • What are Branches?
      • Working in Branches
      • Merging Branches
      • Best Practices For Branching
    • Git Codebase Management Cheat Sheet
  • Conclusion
  • Team Biography
  • References
Powered by GitBook
On this page
  • Clone Repository
  • Pushing Local Changes
  • Updating the Local Workspace

Was this helpful?

Export as PDF
  1. Git & Github - Basics
  2. How To Use Git

Syncing with a Local Workspace

PreviousManaging Repository AccessNextIntroduction to Branching

Last updated 4 years ago

Was this helpful?

Unless you created a repository from an existing local directory, The GitHub repositories created in previous sections are purely remote repositories. To sync these remote repositories with a local workspace you can clone your repository into a local directory. Once you clone your repository into a workspace, you can add changes on your local machine and then push them to your remote repository.

Clone Repository

To clone your repository you first need an HTTPS link. If your repository is empty you can copy this from the top of your repository page.

If the repository is not empty, you can copy the HTTPS link by:

  1. Clicking on the "code" section on the GitHub repository page

  2. Clicking “code” button

  3. Clicking “HTTPS”

  4. Clicking the clipboard icon

In the command line enter the following:

$ cd [your_local_workspace]
$ git clone [HTTPS link]

Now your remote repository is synced to your local workspace. All changes that are explicitly committed and pushed will be added to the remote repository.

Pushing Local Changes

To push local changes in your cloned repository to the current branch, enter the following commands in your cloned repository:

$ git add --all
$ git commit -m "your commit message"
$ git push

Updating the Local Workspace

When collaborating with others, you should always make sure you are working with the latest version of the repository before making local changes. To update your local workspace to the latest commit of the remote repository, enter the following command in your local workspace directory:

$ git pull

At a high level, Git performs Version Control for repositories through branches. Each repository has a master branch which is the mainline of the project (see ). Code collaborators can create different versions of the same repository by creating new branches diverging from the master branch (see ). Every branch, including master, keeps track of the changes explicitly committed to it..

Git add marks the files you want to include in the next commit (see ). Using “git add --all” marks all files in the current directory. For more Git add options see . At a high level, Git commit stores a “snapshot” of the state of marked files to save to the branch (see article). Finally “git push” transfers your commit to your remote repository (see article).

Git pull fetches and merges the latest commit of the branch your local workspace is currently on. For more on Git pull see documentation.

Git branches guide
Git branches guide
Git add guide
Git add guide
this
this
this