Git Course 0%

Editing in the browser and pulling it back

Intermediate GitLab UI GitHub UI Git CLI ≈ 7 min

What you will learn

  • How to edit a file and commit it from GitLab or GitHub, on a branch
  • Why your local clone does not know about it until you pull
  • When browser editing is the right tool and when it is not

After this lesson you can

  • I can fix a typo from any computer and bring the commit back to my clone

Why this matters

Someone reports a typo in the FAQ while you are on a phone, or on a machine with no Git installed. Cloning, branching and pushing for one character is out of proportion. Both platforms let you edit a file, commit it to a branch and open a merge request without leaving the browser, and the whole thing takes a minute.

What browser editing is good for

Good for Not good for
A typo, a broken link, a wrong number Anything you should test before committing
A small documentation change reviewed by eye Changes across several files that belong together
A quick fix while away from your own machine Renaming or moving files (possible, but awkward)
Reviewing and applying a reviewer's suggestion Anything where you want a preview beyond Markdown

The limit is not technical, it is that you cannot run anything: no tests, no Markdown linter, no program. The pipeline runs after you commit, so a browser edit that breaks the build fails on the server rather than on your laptop.

The commit is real

The most important thing to understand is that a browser edit is an ordinary commit on an ordinary branch. It has your name, a message and a hash; the pipeline runs; a merge request can be opened. And your clone knows nothing about it until you fetch:

Terminal
$ git fetch
From https://gitlab.com/you/trailguide
   216f956..01268bf  main       -> origin/main
Terminal
$ git status
On branch main
Your branch is behind 'origin/main' by 1 commit, and can be fast-forwarded.
  (use "git pull" to update your local branch)

nothing to commit, working tree clean
Terminal
$ git pull
Updating 216f956..01268bf
Fast-forward
 docs/faq.md | 4 ++++
 1 file changed, 4 insertions(+)

That is the entire relationship: the browser made a commit on the remote, and git pull brought it home. Lab 2 walks this exact sequence.

How to do it

The terminal cannot edit files on the server; the browser is the point of this lesson. What the terminal does is collect the result:

Terminal
$ git pull

If you have local work in progress, commit or stash it first (lesson 5.7), then pull.

Common mistakes

  • Keeping the suggested commit message. Update faq.md tells nobody anything. Write a real subject, with the issue number (lesson 5.4).
  • Committing straight to main when a merge request was expected. On unprotected branches the platform lets you; check the target-branch choice before committing.
  • Editing in the browser while you have local uncommitted work in the same file. The pull that follows conflicts. Push your local work first.
  • Using the browser for anything testable. No tests run until the pipeline. For code, clone.
  • Forgetting to pull afterwards. Your next local commit starts from an older base, and you meet a rejected push.

Try it yourself

Goal: make a browser commit on a branch and bring it into your clone.

  1. On your playground project's website, open docs/faq.md and edit one line.
  2. Write a proper commit message, and choose to create a new branch rather than committing to main.
  3. Open the merge request the platform offers, then merge it.
  4. In your terminal: git fetch, git status, and read the "behind" line.
  5. git pull and confirm the change is in your local file.

Expected result: step 4 reports behind 'origin/main' by 1 commit; step 5 fast-forwards and the file on your disk now contains the browser edit.

Show solution

Choosing a new branch in step 2 is what makes this a normal contribution rather than a direct commit to main; it is also what a protected branch would have forced. The fetch in step 4 proves once more that your clone learns nothing until it asks.

Check yourself

1. You committed a fix in GitLab's web editor. What does your local clone know about it?
2. Which change is a poor fit for browser editing?
3. On a protected main, what does the platform do when you commit a browser edit?

Key terms

Commit Branch Merge request (MR) Pull Fetch