GithubHelp home page GithubHelp logo

git-lesson's Introduction

git-lesson

Repo to practice git methods

Install git

sudo apt install git -y

Git usage

  • Set parameters
git config --global.user.name "First Last"
git config --global user.email "[email protected]"
  • clone a repo
git clone <url>
  • New directory will be in terminal working path

Git Status

  • Up to date with origin/main
git status

cat .git/config

Branch

  • Create branch
  • Make change
  • Merge change

Optional Install VSCode

Work on Repo

  • Add a module similar to moduleP
    • my_module

Merge

- git status
	- Shows files that aren't being tracked in red
- git add filename.py
- git add -all
- git status
	- Files will now be displayed
- git commit -m 'commit message'
- git status
	- Will now be ahead of main
- git push
	- Publish local changes
	- If there is changes to main since you made the pull you will get a message to pull changes
	- git pull

The Lesson from working on Main

Working on the same branch causes issues with syncing changes

  • Set global
    • git config pull.rebase false

Create Branch

  • git branch
    • Shows known branches
  • git checkout -b branchName
    • Switches to branch
    • Creates the branch if it is new
  • git branch
    • Shows new branch
  • Make changes to files in branch
    • git add fileName

Merge changes back to main

  • Make sure required files are added
  • git commit -m 'commit message'
  • If new branch
    • Create new branch origin
    • git push --set-upstream origin branch
  • git pull
  • git checkout main
  • git pull
  • git merge --no-ff --no-commit branchName
    • --no-ff no fast forward
    • --no-commit
      • stops before commiting
  • git status
  • git commit -m 'merged branchName into main'
  • git push

Protecting main

  • Setting up protections on main will prevents everyone being able to commit to main without getting it approved first
  • Only maintainers of the project can make changes on that branch

git-lesson's People

Contributors

paul7dxb avatar zebra-spots avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.