For example, this is the status of a branch in my local repository:
14:56:15 /srv/www/gamersmafia/current[max-decisiones]$ git status
# On branch max-decisiones
# Changes not staged for commit:
# (use "git add <file>..." to update what will be committed)
# (use "git checkout -- <file>..." to discard changes in working directory)
#
# modified: app/controllers/respuestas_controller.rb
# modified: app/helpers/application_helper.rb
# modified: app/models/decision.rb
# modified: app/models/gm_portal.rb
# modified: app/models/term.rb
# modified: app/views/respuestas/index.html.erb
#
# Untracked files:
# (use "git add <file>..." to include in what will be committed)
#
# app/assets/stylesheets/old/sprites/games_sprites.css
#
If I want to add files to commit them, I have to write the path to the file, or select and paste it after writing git add
.
Is there a faster way to work with git selecting files to add, checkout, etc? For example, if I just want to add 2 files for commit?
To add and commit files to a Git repository Create your new files or edit existing files in your local project directory. Enter git add --all at the command line prompt in your local project directory to add the files or changes to the repository. Enter git status to see the changes to be committed.
To add multiple files in Git, first, navigate to the directory where the untracked files are present and execute the “$ git add” command with the required files name. Then, use the “$ start” command to open added files one by one, make changes and save them.
The git add command adds a change in the working directory to the staging area. It tells Git that you want to include updates to a particular file in the next commit.
You could just add them (also the newly created files) with:
git add -A .
And then commit. If you want to just add some of them you can use add interactively:
git add -i
git
will ask for what files you want to add. If you're using linux or a mac you can create an alias in your shell to make the command shorter and so even faster.
Another solution is to use a wrapper for your editor/IDE. You can find a wrapper for almost any developing tool (from eclipse to VIM). This wrappers usually let you perform some actions quickly, just like add
or commit
the file your editing. You can file a complete list in the git wiki.
To add everything, both tracked and untracked files. Add a dot after add. For example:
git add .
If you just wanted to commit the files that are already tracked without adding new ones, you can use the "-a" flag for git commit. Like:
git commit -a
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With