Git Commands
Git Commands
Configure global git ignore
-
try to get the current config
\$ git config --get core.excludesfile
-
if it doesn’t exist, you can create a file
\$ git config --global core.excludesFile '~/.gitignore' \$ git config --get core.excludesfile \$ ~/.gitignore
Two ways of creating a GitHub repository
There are two ways to create a Github repository. One is pushing from local to remote, another is pulling from remote to local.
1. Create a repo on Github and Clone it to local
- Create a repo on Github
- Go to the project, find a URL
- Go to your local folder, run command
git clone URL
2. Create a local repository, push it to your Github account
- Go to your Github page, create a new repository, select Push an existing repository, get your repo address
- Create a directory to contain the project, go into this directory
git init
to initialise it as a Git Repository- You’ll probably want to create a
.gitignore
file - Run
git add .
andgit commit -m "Commit message"
- In your local, run
git remote add origin REPO_URL
. You can get your REPO_URL fromgit remote -v
- Push your code:
git push -u origin YOUR_BRANCH
, in this case can begit push -u origin master
3. Configure remote url
# works without internet
\$ git config --get remote.origin.url
# works with internet
\$ git remote show origin
References
Last Updated: Dec 2019