Re: the git add command

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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.




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux