git config --global user.email "you@example.com"
git config --global user.name "Your Name"git config --local user.email "you@example.com"
git config --local user.name "Your Name"git config --global --unset user.email
git config --global --unset user.namegit init
git add README.md
git commit -m "first commit"
git branch -M main
git remote add origin https://github.com/[username]/[repo-name].git
git push -u origin maingit add .
git commit -m "something has changed"
git push origin main
git pull origin main| Discription | Command |
|---|---|
| Check your login details | git config --list |
| Check Status or State of your repo | git status |
List Branches -a denotes all Branches |
git branches |
logs ,--oneline denotes all commit without extras |
git log |
| Discription | Commands |
|---|---|
| list your branches. a * will appear next to the currently active branch | git branch |
| create a new branch | git branch branch-name |
| switch to another branch and check it out into your working directory | git checkout Branch-Name |
| merge the specified branch’s history into the current one | git merge branch_name |
git clone --bare <https://github.com/exampleuser/public-repo.git>
cd public-repo.git
git push --mirror <https://github.com/yourname/private-repo.git>Eventually, any interesting software project will come to depend on another project, library, or framework. Git provides submodules to help with this. Submodules allow you to include or embed one…
You can add "sub_repo" as a submodule of main. In the main repository:
git submodule add https://github.com/<user>/sub_repo part_of_main_nowNewer versions of Git will do this automatically, but older versions will require you to explicitly tell Git to download the contents of sub_repo:
git submodule update --init --recursiveJoining a project using submodules
git clone --recursive <main repo url>