Giter Club home page Giter Club logo

how2git's Introduction

How2Git

Clone

To clone a repo, use

git clone [email protected]:<user>/<repo>

Add a Feature

Make sure you're on stage, which is our default base for new features

git checkout origin stage

Create a new branch for the new feature. Use lowercase and underscore for spaces

git checkout -b feat-cool-feature

Make some changes, and stage them

git add -A
git commit -m "feat: add cool feature a"

If you've only made changes to existing files, adding and commiting can be done with a single command

git commit -am "feat: add cool feature b"

Commit

Commit your changes using a commit message on the following format

  • conf - commit contains only configuration updates
  • feat - commit adds new functionality
  • fix - commit fixes a bug
  • ref - commit contains a refactor of existing code, no new functionality

Use imperative form in commit messages. That is, write what you intended to do, not what you did: "add new feature", not "added new feature"

NB: If you feel like your commit fits several of these tags, that probably means you're commiting too much at once. A single commit should only cover a single feature! If you did some refactoring, and updated some configurations, then create two separate commits: One for each. Also, if you feel like your commit message requires the word and, that probably is a sign that you're commiting too much!

Workflow and Merging

Perhaps the most scary part of using git is the fear of losing work and resolving merge conflicts. However, these issues can mostly be avoided by using a swift workflow.

Example of workflow

Add a feature

git branch -b feature_c
echo some changes >> feature_c.txt
git add -A
git commit -am "feat: add neat feature c

Update your local repo, and merge it into your new feature branch

git checkout stage
git pull origin stage
git checkout feat-cool-feature
git merge stage

Make sure everything still works, and then create a Pull Request through GitHub or SourceTree.

NB: If you're familiar with Rebase, consider rebasing your branch on top of stage before merging the feature in. This will remove unecessary commits, and clean up the history.

git fetch -a
git rebase -i origin/stage
git push -f <your branch>

Q & A

  • What is origin? Origin is the remote repository. On the other hand, HEAD is the current state of local repo on your own computer.

how2git's People

Contributors

habitats avatar

Watchers

 avatar  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.