Git Product home page Git Product logo

2022-03-09-git-collab's Introduction

2022-03-09-git-collab

  • git clone <URL>: "downloads" the repository to the current directory

    • git init: creates a git repo locally
  • git branch <NAME>: creates where HEAD is

    • git branch -a: list all your branches
  • git switch <NAME>: switch to branch

    • git checkout <NAME>: "older" way to switch branches
    • shortcut: git switch -c <NAME>: create and move in 1 step
    • git checkout -b <name>: older way to create and move
    • The PR will updat if you push new changes
  • Cleaning up after PR merge

    • Delete the branch on the remote
    • git fetch --prune: update the local history
    • git branch -d <NAME>: delete the branch
      • Note: lower-case d (use -D for force delete)

Changes to b1 commit 1 Changes to b1 commit 2 Changes to b2 commit 1 Changes to b2 commit 2

set up for rebase conflict

git checkout -b conflict_branch_1
echo "Changes to b1 commit 1" >> README.md
cat README.md
git commit -am "b1 c1"
echo "Changes to b1 commit 2" >> README.md
git commit -am "b1 c2"
git log --oneline --graph --all
git checkout main
git log --oneline --graph --all
git checkout -b conflict_branch_2
echo "Changes to b2 commit 1" >> README.md
git commit -am "b2 c1"
echo "Changes to b2 commit 2" >> README.md
git commit -am "b2 c2"
  • Branch protection rules force you to practice collaboration on your own
  • git reset --hard <HASH>: force move current branch to location
  • git log --oneline --graph --all

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.