Before I do mistake, I need to know what I'm about to do is correct. I did some researches but still want make sure because I'm new to GIT and scared of messing whole project. Yes there are a lot of examples but I'm confused. That's all.
I have 3 files in local GIT and just want to commit one of them and push it to live GIT. So are these steps correct?
WHAT I THINK I SHOULD DO !!!
sudo git add web/js/admin/design.js
sudo git commit -m 'Bug fix'
sudo git push origin sprint-6
GIT STATUS:
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: src/Hello/AdminBundle/Controller/DesignController.php
modified: web/js/admin/design.js
Untracked files:
(use "git add <file>..." to include in what will be committed)
src/Hello/AdminBundle/Utility/DesignPublisher.php
no changes added to commit (use "git add" and/or "git commit -a")
Push Single file to git For this, you have to run specific command to push the only single file to git. Above all commands are related to push the only single file to git but sometimes we want to push only two files to git in a single commit.
On GitHub.com, navigate to the main page of the repository. Above the list of files, using the Add file drop-down, click Upload files. Drag and drop the file or folder you'd like to upload to your repository onto the file tree.
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.
Git Push Recap In the command line, go to the root directory where your local files are. Optionally initialize the local directory (git init). Add the your file changes (git add) and commit your changes (git commit). Finally, push your changes of the local file or repository to GitHub (git push).
You commit only files that are added to the repository. So if you need only one file then add only the one file.
git add src/Hello/AdminBundle/Controller/DesignController.php
And then commit it. Files that are untracked are not included in the repo. There you have to add it first.
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