git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Seth House <seth@eseth.com>
To: Knapperig knaapie <isaacvanson@kpnmail.nl>
Cc: git@vger.kernel.org
Subject: Re: the git add command
Date: Tue, 16 Feb 2021 10:54:41 -0700	[thread overview]
Message-ID: <YCwG4SkN4unSANjX@ellen.lan> (raw)
In-Reply-To: <66eb4eba-ed94-b467-336b-dbe6f398d8af@kpnmail.nl>

On Tue, Feb 16, 2021 at 04:21:44PM +0100, Knapperig knaapie wrote:
> A screenshot of the problem occurring on the command line is attached.
> Holler if you need more info.

Hello. Everything in this screenshot looks working as intended to me.
I'll walk through line-by-line to explain what is happening.

1.  `git commit -m 'tests weg uit admin file'`

    The `admin.py` file was modified but not yet staged which is why Git
    reported "no changes added to commit" and no commit was created.

2.  `git add`

    This command requires an argument which is why Git reported "Nothing
    specified, nothing added".

3.  `git add ookleuk/admin.py`

    This succesfully staged the file for commit.

4.  `git push`

    The admin file has been staged but a commit for it has not yet been
    created which is why Git reported "Everything up-to-date".

5.  `git commit -m 'tests weg uit admin file'`

    This successfully created a commit containing the admin file.

6.  `git push .`

    The first argument to the push command is the name of a remote to
    push to.

    This can also be a file path which in this case is the path to the
    local repository that you're currently working in which is why Git
    reports "Everything up-to-date".

    Without any arguments it'll use the default behavior [1] (the
    current branch is pushed to the corresponding upstream branch). Or
    it's also common to specify name of a remote (e.g., "origin"). One
    of these would be a good choice for this workflow.

    [1] https://www.git-scm.com/docs/git-push#_description

7.  `git add .`

    Nothing was staged since there were no modified files.

8.  `git push .`

    Same as above: pushing changes from the local repository to the same
    local repository. `git push` without arguments would do the trick.

9.  `git status`

    This reports there is one commit that is ready to push -- the commit
    from #5. It also looks like the file was modified again after that
    commit was created.

10. `git add admin.py`

    This did not work because `git add` is looking for a file named
    `admin.py` in the current directory. It would work with the full
    path like in #3, or it would work if the current directory was the
    `ookleuk` directory but from the shell prompt and the `git status`
    output from the previous step it looks like the current directory is
    `vinkmoi` and not `ookleuk`.

11. `git add .`

    This successfully staged the new changes to the admin file but
    a commit has not yet been created.

12. `git push`

    This successfully pushed the commit created in #5.

    The commits that were pushed can be viewed in GitHub [2] or on the
    CLI with `git log --oneline 5a0c6bb...966fde2`. If `git status` were
    run after this it would report your branch is up-to-date with
    origin/master and there is one file currently staged for commit.

    [2] https://github.com/Ivsvinkmoi/Django_project/compare/5a0c6bb...966fde2

Based on that screenshot, I'd suggest reading about staging vs.
committing and pushing and remotes. Also to pay close attention to which
arguments are given to which commands and what directory each command is
run from.

The Git website has excellent written and video tutorials [3] that cover
those topics and the Google Groups mailing list [4] is a good resource
to discuss Git usage and questions with other people that are also
learning Git.

[3] https://www.git-scm.com/doc
[4] https://www.git-scm.com/community
    https://groups.google.com/g/git-users

You said:

> I want to be sure I'll be able to only upload
> specific files in the future.

Which is a great workflow and definitely possible! Stick with it and
you'll get there. If your Git experience is anything like mine: it's
a long road to learning it at first but the time investment will be more
than worthwhile in the long run.

Cheers.


  reply	other threads:[~2021-02-16 17:55 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-02-16 15:21 the git add command Knapperig knaapie
2021-02-16 17:54 ` Seth House [this message]
2021-02-17 20:48 ` Konstantin Tokarev

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=YCwG4SkN4unSANjX@ellen.lan \
    --to=seth@eseth.com \
    --cc=git@vger.kernel.org \
    --cc=isaacvanson@kpnmail.nl \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).