* the git add command
@ 2021-02-16 15:21 Knapperig knaapie
2021-02-16 17:54 ` Seth House
2021-02-17 20:48 ` Konstantin Tokarev
0 siblings, 2 replies; 3+ messages in thread
From: Knapperig knaapie @ 2021-02-16 15:21 UTC (permalink / raw)
To: git
[-- Attachment #1: Type: text/plain, Size: 681 bytes --]
Hello there,
I recently made a change to a project, and for adding a file I changed
to the staging area I used the command 'git add ookleuk/admin.py'. At
this point I was logged into the parent directory of 'ookleuk' on the
command line. However, when I used the push command, I got the response
'everything up to date'. For now it isn't a problem, because when I used
the command 'git add .' everything worked fine and the files in the
repository got updated, but honestly, I want to be sure I'll be able to
only upload specific files in the future.
A screenshot of the problem occurring on the command line is attached.
Holler if you need more info.
Greetings, Isaac
[-- Attachment #2: Git issue.png --]
[-- Type: image/png, Size: 220841 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: the git add command
2021-02-16 15:21 the git add command Knapperig knaapie
@ 2021-02-16 17:54 ` Seth House
2021-02-17 20:48 ` Konstantin Tokarev
1 sibling, 0 replies; 3+ messages in thread
From: Seth House @ 2021-02-16 17:54 UTC (permalink / raw)
To: Knapperig knaapie; +Cc: git
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.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: the git add command
2021-02-16 15:21 the git add command Knapperig knaapie
2021-02-16 17:54 ` Seth House
@ 2021-02-17 20:48 ` Konstantin Tokarev
1 sibling, 0 replies; 3+ messages in thread
From: Konstantin Tokarev @ 2021-02-17 20:48 UTC (permalink / raw)
To: Knapperig knaapie, git@vger.kernel.org
16.02.2021, 19:08, "Knapperig knaapie" <isaacvanson@kpnmail.nl>:
> Hello there,
>
> I recently made a change to a project, and for adding a file I changed
> to the staging area I used the command 'git add ookleuk/admin.py'. At
> this point I was logged into the parent directory of 'ookleuk' on the
> command line. However, when I used the push command, I got the response
> 'everything up to date'. For now it isn't a problem, because when I used
> the command 'git add .' everything worked fine and the files in the
> repository got updated, but honestly, I want to be sure I'll be able to
> only upload specific files in the future.
In this case you should better use git gui to add files. It allows not only to add
individual files quickly, but also add specific part of changes in a file, e.g. omit
leftover debug lines or changes related to another topic. Corresponding
command line tools like git add -p or git add -i are quite tedious to use.
>
> A screenshot of the problem occurring on the command line is attached.
> Holler if you need more info.
>
> Greetings, Isaac
--
Regards,
Konstantin
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2021-02-17 20:59 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-16 15:21 the git add command Knapperig knaapie
2021-02-16 17:54 ` Seth House
2021-02-17 20:48 ` Konstantin Tokarev
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
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 read-only IMAP folder(s) and NNTP newsgroup(s).