I'm just entering into the wonderful world of git.
I have to submit a bunch of changes that I've made on my program, located in a directory called /var/www/myapp
.
I created a new directory /home/mylogin/gitclone
. From this directory, I did a git clone
against the public repo and I was able to get the latest copy created.
I'm now trying to figure out how to take all the files in my working folder (/var/www/myapp
) and "check them in" to the master repository.
From /home/mylogin/gitclone
, I tried git add /var/www/myapp
but I'm getting an error that the folder I tried to add is outside the repository.
Can you give me a few pointers on what I'm doing wrong? Also, I'd like to add everything, whether it's different from the master or not. Thanks.
For the second situation, you need to initialize the Git repository in your project folder. To do so, you need to navigate to the correct folder and then run the command git init , which will create a new empty Git repository or reinitialize an existing one.
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. However, git add doesn't really affect the repository in any significant way—changes are not actually recorded until you run git 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.
First in the clone folder you can create a Branch (so the master stay untouched)
git branch [branch_name]
After, just copy the files you want from your old folder to the clone folder.
When you are done, just add / commit your change and Merge your branch into the "master" branch. It will look like to something like this:
git add . git commit -m "Comments" git checkout master git merge [new_branch]
Try this tutorial from GitHub.
You'll have to move all the files from /var/www/myapp to /home/mylogin/gitclone and then do a git add .
and then git commit -m "Your message"
.
When upgraded to git version 2.12.2 that error appeared, I nooted the i add the file with a full path like:
git add c:\develop\project\file.text
when removed the full path it start working, like:
git add file.text
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