How to push an existing folder to the GitHub
switch to your folder (E.g cd ~/testFolder
)
Note: You are erase the git files of the old repository completely by usingrm -rf .git
before git init
And you may have a problem while you push it to the master, and if the error is like the following:
You can fix this problem by pushing it to the git forcedly using commandgit push -u origin master -f
If you are pushing a folder to the repository which contains some files already, you need to merge the local branch with the remote branch first. The command should be:git pull --rebase origin master
How to clone an existing repository from GitHub
|
|
You may need to list the remote branch, and you can do that by using:
|
|
Then you can download the repository from GitHub usinggit checkout branchName && git pull
(Switch to the targeted branch and pull the code)
This post is still updating through my programming experience. π Feel free to leave a comment and tell me which problem you are facing with Git. It will be good to configure that out together. π
How to ignore folders or files
I have faced a problem that when I am developing a React App, I donβt want to add the node_modules/ to my git repository. So how can I ignore it when I uploading it?
Type the following:
|
|
Then add
|
|
to the .gitignore file (type: :wq to quit and save).
Then you will ignore node_modules/ automatically when you git add and git commit!