Skip to content

GreetVdL/GITguide

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 

Repository files navigation

A GIT guide written in Markdown 📓

Cheat sheets 👀

---> Markdown cheatsheet

---> GIT cheatsheet


GIT guide for local-GitHub connected setup 🚀

  1. Make a local folder with your files in it and open the folder in VSCode.

$ code .

  1. Let GIT track the entire folder.

$ git init

$ git add .

$ git commit -m "initial commit"

  1. If you make changes, commit them.

$ git commit -am "commit message"

  • When new files were added, add them first: $ git add . $ git commit -m "commit message"
  1. Create a new GitHub repository.

  2. Make the remote connection. You can have multiple remotes so each requires a name. The primary remote is typically named origin.

$ git remote add origin <URLFROMGITHUB>

  1. Push to your remote to sync them.

$ git push -u origin main

  • If you have only one remote connected and one branch 'main', you can omit the remote and branch names. $ git push The upstream flag -u refers to the repository that one will be pulling from by default. Now you can use the git pull and git push commands without arguments.
  1. If you make remote changes, pull them in.

$ git pull <REMOTENAME> <BRANCHNAME>

  • If you have only one remote connected and one branch 'main', you can omit the remote and branch names. $ git pull

GIT guide for merging 🌉

  1. First, move into the branch you want to merge into.

$ git checkout <BRANCHNAME>

  1. Tell GIT what branch you want to merge into the branch you are currently in.

$ git merge <BRANCHNAME>

  1. You can delete the branch that just has been merged.

$ git branch -d <BRANCHNAME>

  1. You can also delete the branch on your remote on GitHub.

$ git push <REMOTENAME> --delete <BRANCHNAME>


Other useful commands 💡

  • clone a repo and set the new name of the cloned directory:

$ git clone <URL> <NEWDIRECTORYNAME>

  • See the status of changes to a repository

$ git status

  • See what has been changed

$ git diff

  • Set a new GitHub repo as origin to your clone:

$ git remote set-url origin <new-repo-url>

  • Rename the local master branch to main:

git branch -m master main

  • View remote addresses

$ git remote -v

  • See a list of your commits

$ git log

  • See a list of your local branches

$ git branch –l

  • See a list of your remote branches

$ git branch –r

  • See a list of all your branches, locally and remote

$ git branch –a

  • Make a new branch

$ git branch <BRANCHNAME>

  • Go into a branch

$ git checkout <BRANCHNAME>

  • Rename a branch you're currently on

$ git branch -m <NEWBRANCHNAME>

About

📓 A GIT guide for beginners

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published