Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4006062
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T08:28:10+00:00 2026-05-20T08:28:10+00:00

I am trying to understand how git works. So I initialized an empty repo

  • 0

I am trying to understand how git works. So I initialized an empty repo and added a file to it as following.

cd /home/adnan/workspace
mkdir git-test
cd git-test
git init
touch README
git add .
git commit -m "initial commit"

Now I cloned it this repo using the following sequence of commands

cd /home/adnan/Desktop
git clone /home/adnan/workspace/git-test

after that I made changes to README file, committed them and pushed them to the first repo using following commands

cd /home/adnan/Desktop/git-test
vi README
git commit -a -m "second commit"
git push

Now running git log in both repos shows same thing i.e

commit
cdf192f7e26e734c7a56cc830ade2e2d13c6fb0d
Author: Adnan Waheed
Date:
Tue Mar 1 14:05:12 2011 +0500

second commit

commit
f8b75838e728e46cae949f66ff86d29c0864d976
Author: Adnan Waheed
Date:
Tue Mar 1 14:03:23 2011 +0500

initial commit

but I cant figureout how to get the changes in the original repo i.e /home/adnan/workspace/git-test. If I try to do git checkout, I get this message:

M   README

How do I get the changes that I made in the cloned repo and pushed?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T08:28:10+00:00Added an answer on May 20, 2026 at 8:28 am

    Did you see an error message when you did git push? Something like this (assuming git > 1.7.0)?

    $ git push
    Counting objects: 5, done.
    Writing objects: 100% (3/3), 246 bytes, done.
    Total 3 (delta 0), reused 0 (delta 0)
    Unpacking objects: 100% (3/3), done.
    remote: error: refusing to update checked out branch: refs/heads/master
    remote: error: By default, updating the current branch in a non-bare repository
    remote: error: is denied, because it will make the index and work tree inconsistent
    remote: error: with what you pushed, and will require 'git reset --hard' to match
    remote: error: the work tree to HEAD.
    remote: error: 
    remote: error: You can set 'receive.denyCurrentBranch' configuration variable to
    remote: error: 'ignore' or 'warn' in the remote repository to allow pushing into
    remote: error: its current branch; however, this is not recommended unless you
    remote: error: arranged to update its work tree to match what you pushed in some
    remote: error: other way.
    remote: error: 
    remote: error: To squelch this message and still keep the default behaviour, set
    remote: error: 'receive.denyCurrentBranch' configuration variable to 'refuse'.
    To /home/pfarmer/git-test/git-test
     ! [remote rejected] master -> master (branch is currently checked out)
    error: failed to push some refs to '/home/pfarmer/git-test/git-test'
    

    Basically by default you can’t push to a non-bare repository. But what you can do is a git pull, so try:

    cd /home/adnan/workspace/git-test
    git pull /home/adnan/Desktop/git-test
    

    and you should see something like:

    $ git pull ../git-test2/
    From ../git-test2
     * branch            HEAD       -> FETCH_HEAD
    Updating 161aeea..c66b221
    Fast-forward
     README |    1 +
     1 files changed, 1 insertions(+), 0 deletions(-)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to understand how Git works better. Given some arbitrary files and
I am trying to understand if I really have any case for using git/mercurial.
If there is anyone that can help me understand why this git repo isn't
I'm new to git and I'm trying to understand if it can solve my
While trying to install Rails admin, I added it to my gem file as
While trying to install Rails admin, I added it to my gem file as
I am trying to understand the code in this page: https://github.com/corroded/git-achievements/blob/gh-pages/git-achievements and I'm kinda
I'm really new to git and I've been trying to understand why git keeps
I am trying to understand and learn how to use subversion or git. Which
Trying to understand an fft (Fast Fourier Transform) routine I'm using (stealing)(recycling) Input is

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.