Single logo
  • Courses
  • Blog
  • About
Join on SkoolJoin on Skool

In this topic

Java
  • Install Java 25 (JDK) and IntelliJ IDEA, Then Run Your First Program
  • Use Claude Agent, Copilot or Junie Inside IntelliJ IDEA
  • Java Hello World with Maven: What the JDK Does and What Maven Adds
  • Java Variables, Keywords and Naming Rules
  • Maven in IntelliJ: pom.xml, Dependencies and the Build Lifecycle
  • Java Primitive Types and Memory: What int x = 5 Really Does
  • Java Strings and Text Blocks: Quotes, Concatenation and parseInt
  • Java Operators: Arithmetic, a++ vs ++a, Precedence, && || and the Ternary
  • Java Type Casting: Widening, Narrowing and Converting Text to Numbers
  • Java Practice Lab: A Cafe Bill with Variables, Operators and Casting
  • Java if, else and switch: Braces, Else-If Ladders and the Modern Switch
  • Java Loops: for, while, do-while and for-each
  • Java break, continue and Nested Loops
  • What's New in Java 21 to 25: Compact Source Files and Sequenced Collections
  • Java Arrays: Indexes, Default Values, Loops and 2D Grids
  • Java Methods and Overloading: Parameters, return and Pass-by-Value
  • Java Scope, Code Blocks and the Call Stack
  • Read User Input in Java with Scanner (and the Leftover Enter Trap)
  • Java Practice Lab: A Gym Weekly Tracker with Loops, Arrays and Methods
  • Debugging Java in IntelliJ: Stack Traces, Breakpoints and a Better AI Prompt
  • Java var: Let Java Infer the Type
  • Push and Pull in IntelliJ: Two Developers, One GitHub Repository, a Rejected Push and a Conflict
  • Java Classes and Objects: One Blueprint, Many Cars
  • Java Constructors and the this Keyword
  • Java Instance Methods, Getters, Setters and toString
  • Java static: Fields, Methods and Blocks Shared by the Whole Class
  • Java Packages and Imports: Every Class Has an Address
  • Java Access Modifiers and Encapsulation: Private Data, Public Methods
  • Java final and Immutable Objects: Assign Once, Share Safely
  • Java Strings as Objects: The String Pool, == vs equals, StringBuilder and printf
  • Java Practice Lab: A Library Book Catalogue with final Fields and StringBuilder
  • Java Inheritance: extends, super and the Order Objects Are Built
  • Java Method Overriding, @Override and the Object Class
  • Java Polymorphism: Upcasting, Dynamic Dispatch and Downcasting
  • Java Composition: Has-A vs Is-A
  • Java Abstract Classes: A Parent That Leaves One Blank
  • Java Interfaces: Contracts and Multiple Inheritance
  • Java Nested, Inner and Anonymous Classes
  • Java Enums with Fields, Methods and switch
  • Java Practice Lab: Payment Processing with an Interface, an Abstract Class and an Enum
  • Java Records: A Whole Data Class in One Line
  • Java Sealed Classes and Interfaces
  • Java Pattern Matching with instanceof and switch
  • Java Record Patterns: Unpacking a Record
  • Java equals and hashCode: Why a HashSet Needs Both
  • From Arrays to Collections: The Java Collections Framework Map
  • Java Wrapper Classes and Autoboxing
  • Java ArrayList: The Stretchy Array
  • Java LinkedList vs ArrayList: Nodes or an Array
  • Java Sets: HashSet, LinkedHashSet and TreeSet
  • Java Sorting with Comparable and Comparator
  • Java Maps: HashMap, LinkedHashMap and TreeMap
  • Java Stacks, Queues and Deques: ArrayDeque and PriorityQueue
  • Choosing a Java Collection: Immutable and Sequenced Collections
  • Java Exception Handling: try, catch and finally
  • Java throw, throws, Checked vs Unchecked and Custom Exceptions
  • Java try-with-resources and Clean Error Handling
  • Java Generics: Type-Safe Containers
  • Java Generic Methods, Bounded Types and Wildcards
  • Java Lambdas and Functional Interfaces
  • Java Built-in Functional Interfaces: Predicate, Function, Consumer, Supplier
  • Java Optional: Saying Maybe Without null
  • Java Streams I: filter, map and reduce
  • Java Streams II: Collectors, groupingBy and flatMap
  • Why Concurrency: Processes, Threads and the Main Thread in Java
  • Creating Threads in Java: Thread, Runnable and Lambdas
  • Java Thread Lifecycle: sleep, join and interrupt
  • Java Race Conditions and synchronized
  • Java volatile and Atomic Variables
  • Java ExecutorService and Thread Pools
  • Java Callable, Future and CompletableFuture
  • Java Locks, Deadlock and tryLock
  • Java Concurrent Collections and Virtual Threads
  • Why Slow Work Belongs off the Request Thread: 202 Accepted and a Job Id in Spring Boot
  • Virtual Threads in Spring Boot: One Property, and the Connection Pool Trap
  • @Async, Named TaskExecutors and Structured Concurrency in Spring Boot
  • Java Files and Directories with NIO.2: Path and Files
  • Reading and Writing Text Files in Java
  • Java Structured Data: Reading and Writing JSON and CSV
  1. Blog
  2. /
  3. Java
  4. /
  5. Basics

Push and Pull in IntelliJ: Two Developers, One GitHub Repository, a Rejected Push and a Conflict

Jack and Emma share hello-app on GitHub using IntelliJ's Git buttons: a first push, a clone, a pull that fast-forwards, a push that gets rejected, and a conflict on line 3 resolved in the merge window. Then the daily pull and push loop.

Chaand Sheikh

·27 November 2026·Updated 28 November 2026Basics

What you will learn

  • Push, clone, commit and pull with IntelliJ's Git menu and know the git command behind each
  • Explain why a push is rejected and fix it with pull, merge, push
  • Resolve a conflict in IntelliJ's three-pane merge window
  • Follow a daily loop for when to pull and when to push

Before you start

  • Git and GitHub Fundamentals: Commits, Branches, Push and Pull
  • IntelliJ IDEA installed

The Git basics are covered in Git and GitHub fundamentals: commit, branch, push and pull. This article watches two developers, Jack and Emma, share one project on GitHub using the Git buttons in IntelliJ. We follow every commit as it travels: a push, a clone, a pull, a push that gets rejected, and one conflict.

One shared copy, two private copies

Think of a class project folder. Each student takes a copy home and writes in it. Nobody sees your pages until you hand them in, and you don't see your friends' pages until you pick up a fresh copy. GitHub is the folder at school, git push is handing your pages in, and git pull is picking up the fresh copy.

Three lanes: Jack's laptop, GitHub and Emma's laptop, each holding its own commits. Push moves commits from a laptop to GitHub; clone and pull move them from GitHub to a laptop. Nothing moves on its own. Jack's laptopGitHub (origin)Emma's laptop push →→ clone / pull A commit only moves when someone pushes or pulls.
Each small box is one commit. GitHub never sends anything to you by itself.

Jack pushes

Jack has created an empty repository called hello-app on GitHub and has two commits on his laptop. In IntelliJ he chooses Git > Push (Ctrl+Shift+K). The dialog lists exactly the two commits GitHub doesn't have yet, under the line main → origin : main: Jack's main branch goes to GitHub's main branch, and origin is the short name for the GitHub address. A small green New tag says main doesn't exist on GitHub yet.

He clicks Push. IntelliJ says it pushed main to new branch origin/main, and a refresh of GitHub shows both files with two commits. In a terminal this is:

git push -u origin main

Push sends commits, not files. Anything you changed but didn't commit stays on your laptop.

Emma clones

On GitHub, Emma clicks the green Code button, picks HTTPS and copies the address. In IntelliJ she clicks Clone Repository, pastes the URL, picks a folder and clicks Clone. The project opens with Hello.java and the README. That's git clone plus the address.

The commit ids on Emma's laptop are exactly the same as on Jack's. A clone isn't a few files copied over; it's an exact copy with the full history.

Emma commits, then pushes

Emma adds a line to the README on how to run the program; the green bar in the gutter marks new lines. She opens the commit window (Ctrl+K), ticks the file, writes add how to run and clicks Commit. That commit is on her laptop only; GitHub knows nothing about it. Then Git > Push: one commit to send, pushed to origin/main. GitHub now has three commits.

Has Jack's README changed? No. Jack has to ask for it.

Jack pulls

Jack chooses Git > Update Project (Ctrl+T), keeps the first option, merge, and clicks OK. One file updated in one commit, and Emma's line appears in his README. The terminal version:

git pull
Updating ...
Fast-forward
 README.md | 2 ++

Pull does two things: it fetches (downloads the new commits) and then merges them with your work. Jack had nothing new of his own, so Git simply moved him forward. That's a fast-forward. In short, pull is fetch plus merge.

Emma pushes first. Jack is rejected.

Now both work at the same time. Jack adds a goodbye line in Hello.java and commits. Emma creates a .gitignore and commits. Different files, and each commit is only on its own laptop.

Emma pushes first. Then Jack clicks Push and gets Push Rejected: the push of current branch main was rejected. In a terminal it says rejected ... (fetch first), with a hint to use git pull before pushing again.

Why? If Git accepted Jack's push, Emma's commit on GitHub would be thrown away, so Git refuses. A rejected push is not an error in your code. It only means someone pushed before you.

Merge, then push again

In the rejection dialog Jack clicks Merge. IntelliJ pulls Emma's commit and creates one extra commit, a merge commit, joining her work and his; the .gitignore appears in his project. The Git log (Alt+9) shows two lines, his commit and hers, joining at the merge commit. He pushes again and it goes through: two commits, his goodbye commit and the merge. The next time Emma pulls, she gets both.

A conflict: the same line, changed twice

Emma changes line 3 of Hello.java to Welcome, Jack, commits and pushes. Jack changes the same line to Hello, team and commits, but forgets to pull first. When he runs Update Project, IntelliJ shows the Conflicts window: Hello.java, modified by you and modified by them. Git can't guess which line should win; that's a human decision.

Inside the file, Git has written both versions between markers:

<<<<<<< HEAD
        (Jack's line 3: Hello, team)
=======
        (Emma's line 3: Welcome, Jack)
>>>>>>> (Emma's commit id)

Between <<<<<<< HEAD and ======= is Jack's version; between ======= and >>>>>>> is Emma's, labelled with her commit id.

Pick the line, commit, push

Jack clicks Merge... and gets three panes: his version on the left, the server's on the right, and the result in the middle. He keeps both ideas and writes Welcome, team; the top right says all changes have been processed. He clicks Apply (in a terminal, git add Hello.java), commits with the message IntelliJ already filled in (merge branch main), and pushes. When Emma pulls, it's a plain fast-forward for her. Now Jack, GitHub and Emma all have the same nine commits.

Changes on different lines merge by themselves. Only the same line changed by two people needs you.

When to pull, when to push

  1. When you sit down to work, pull.
  2. Write code and commit in small steps.
  3. Before you push, pull again; someone may have pushed meanwhile.
  4. Run it, to make sure it still works after the pull.
  5. Push, and share it with the team.

Push when a small piece works (it compiles and runs) and before you stop for the day. Never push code that doesn't compile, because everyone pulls it and the whole team is stuck. And don't sit on your changes for a week: the longer you wait, the bigger the conflicts.

IntelliJ buttons and git commands

IntelliJShortcutgitDirection
Clone Repositorygit cloneGitHub to you, once
CommitCtrl+Kgit add + git commitstays on your laptop
PushCtrl+Shift+Kgit pushyou to GitHub
Update ProjectCtrl+Tgit pullGitHub to you
Git logAlt+9git lognothing moves
Merge after a rejected pushgit pull, then git pushboth ways

It's the same Git underneath; IntelliJ runs these commands for you. GitLab and Bitbucket work the same way.

Common mistakes

  • Expecting a teammate's change to appear by itself. You only get it when you pull.
  • Reading "Push Rejected" as broken code. Pull, merge, then push again.
  • Changing the same lines as a teammate without pulling first. That's how most conflicts start.

Keep going in Java · 22 of 79

Previous
Java var: Let Java Infer the Type
Next post
Java Classes and Objects: One Blueprint, Many Cars
Community · Free to join
Single logo

StudyEasy AI Community

Hosted onSkool

Learn AI engineering, share what you build, and connect with other learners.

  • Free resources: lesson files, notebooks and code

  • Ask questions and join engineering discussions

  • Meet real people learning and building with AI

Join free on Skool

Related course on Udemy

FULL STACK JAVA : JAVA + JSP + SPRING BOOT AI + REACT + VIBE

Java 25, JSP, Hibernate, Spring Boot 4, REST APIs, React and Spring AI.View on Udemy ↗: FULL STACK JAVA : JAVA + JSP + SPRING BOOT AI + REACT + VIBE (paid course, opens in a new tab)

Related posts

Install Java 25 (JDK) and IntelliJ IDEA, Then Run Your First Program

Install JDK 25 (Microsoft Build of OpenJDK) with JAVA_HOME, install IntelliJ IDEA, then point a run configuration at the JDK and the main class and run Hello World.

Use Claude Agent, Copilot or Junie Inside IntelliJ IDEA

Open IntelliJ's AI Chat, pick Claude Agent (the agent behind Claude Code) or Copilot and a model, ask in plain words for Main.java to print the date and time, review the change, and run it.

Java Hello World with Maven: What the JDK Does and What Maven Adds

javac compiles HelloWorld.java into bytecode and java runs it on the JVM. Maven adds one pom.xml, the same folders in every project and one build command. Then a real Maven Hello World in IntelliJ.

Java Variables, Keywords and Naming Rules

A variable is a labelled jar that holds one value at a time. Four small programs show declaring, reassigning, the names Java accepts, the keywords it reserves, and why daysUntilLaunch beats d.

On this page

  • One shared copy, two private copies
  • Jack pushes
  • Emma clones
  • Emma commits, then pushes
  • Jack pulls
  • Emma pushes first. Jack is rejected.
  • Merge, then push again
  • A conflict: the same line, changed twice
  • Pick the line, commit, push
  • When to pull, when to push
  • IntelliJ buttons and git commands
  • Common mistakes
Community · Free to join
Single logo

StudyEasy AI Community

Hosted onSkool

Learn AI engineering, share what you build, and connect with other learners.

  • Free resources: lesson files, notebooks and code

  • Ask questions and join engineering discussions

  • Meet real people learning and building with AI

Join free on Skool

Related course on Udemy

FULL STACK JAVA : JAVA + JSP + SPRING BOOT AI + REACT + VIBE

Java 25, JSP, Hibernate, Spring Boot 4, REST APIs, React and Spring AI.View on Udemy ↗: FULL STACK JAVA : JAVA + JSP + SPRING BOOT AI + REACT + VIBE (paid course, opens in a new tab)

Single logo

Empowering Education, One Course at a Time

About
About usContact us
Legal
Terms of UsePrivacy Policy

© 2026 StudyEasy Organization. All rights reserved.