I have a working repository setup at github.com
I want to push an entire directory to the server (not the sub-directories). How can I do this with out selecting each file individually?
I am working with in a single folder...when I am complete I'm not sure which files I've modified...the directory is relatively small so I just want to simply commit and push everything in the quickest way possible.
How do I do this?
How do I commit and push all files in a directory?
git commit -am "Commit message" will add all the files that have changed to the index, and then commit them. It won't do anything with files that are not currently being tracked.
Follow it up with git push <githubRepo> and it will push all those changes.
the fast way is to make an alias for:
git add -A && git commit
The -A will add any modifications including new files added. The -a on commit will NOT include new files.
Related
I'm trying to commit my project using git commit -m "First.". But throw this error, remembering that I wrote git init.
Other version control systems simply commit whatever files have been changed. Git is different. You must first build the commit by adding them to the staging area with git add. Then you git commit what has been added. This allows you to do some very powerful things, like split big changes into multiple commits.
For the above, add everything with git add . then you can commit. Though you probably want to add .vscode, tmp/, *.lock and any other temporary files and directories to your .gitignore file.
For more, please read Git Basics - Recording Changes to the Repository.
Sadly I've been at it for 3 hours trying to commit my assignment which is a single folder... This is my private github repo
I can't drag the folder since it's limited at 100 files apparently there's like 4000 in my folder?
What I've done is:
$ git clone githuburl
(i now dragged my assignment folder to this repo in my own pc)
$ git add assignmentfolder (pages)
$ git commit -m "first commit"
$ git push origin master
And as you can see it straight up ignored every single file and just committed the folder name?
I think the proper way to do this is:
git clone githuburl
cd githubfoldername
then move all your files there
add a .gitignore file there and exclude node_modules and everything else that has to do with caching and external packages because you don't need them in your repo. Everyone who is going to use your code will be able to install the packages as you did. Just make sure you include the:
packages.json if you used npm
or yarn.lock if you used yarn
Then you can safely
git add --all
git commit -m "your message"
This way you will avoid adding useless files to your repo as #Dmitri Sandler said and you will be able to push everything easily
Generally you should think about files not folders. Try to use wildcard in the path:
git add <folder>/*
It is a good idea to use git status to see what files were staged for commit prior to committing them.
I have created a repository on github, and run the command line git push -u origin master. I just find a folder over there, but I have a lot of file in my folder, but it only uploaded a folder that has no files in it.
How do I upload a folder with lots of files successfully?
I just tried the command git add . and git push -u origin master
It's not working.
Please me teach me what step I missed. Thanks in advance.
You need to add all of the files in the folder. If you actually want to add all of it (not just some), an easy way to do that would be git add -a or git add ReduxSimpleStarter/*.
Then you need to commit them. git commit.
Then push.
I'm guessing, by your description (sorry, it's a bit hard to read. So correct me if I am missing some details to your problem) you're forgetting to commit the changes.
To do this you need to git commit -m "A commit message". It would look something like this all together
git add .
git commit -m "Added a new button"
git push -u origin master
commit just tells git to save the changes you made to it's history. add just tells git that you want those files (in their current state) to be saved next time you commit.
Hopefully that solves your problem.
It looks like you are not committing your changes before pushing.
When you do this:
git add .
your files are adding to the staging area. But you also need to commit them. You can do this by typing this into you command line after doing the 'git add .' command:
git commit -m "your commit message here"
Then you should be able to type 'git push -u origin master' and your files should upload.
I don't know how, but I somehow turned a file into a submodule. So now I can't view it in Github. How do I undo this, to make the file clickable again?
(I've read through answers to similar question in stackoverflow, and they don't make much sense to me...I'm pretty new to git)
You either need to revert to a past commit where that file was not a submodule:
git log path/to/file
git checkout <past_commit> -- path/to/file
Or you could delete that entry and restore the file, adding it and committing it again.
git rm -- path/to/file
# copy the file
git add -- path/to/file
git commit -m "restore file"
Is there a simple way to upload a file to github, if I made a minor modification, without creating a branch?
I'm trying to do something similar to a commit in svn.
Is there any way to perform this?
Once you have repo locally and you modiied file you want to modify.
Open gitbash in directory where .git is present
execute
git add .
git commit -m "Commit Message"
git push origin master