Github Cheat



Introduction to GitHub. Before we jump on to reading the Git Cheat Sheet, let us take a quick relook at the platform. GitHub is a Microsoft developed programme that provides a platform for collaborative work or group projects. Generally in the software development community around five to ten people work on the same project. Git Cheat Sheets from Github. This comment has been minimized. Sign in to view. Copy link Quote reply edwinpopham commented Aug 9, 2017. Cool easy place to get a. GITHUB FLAVORED MARKDOWN GitHub.com uses its own version of the Markdown syntax, GFM, that provides an additional set of useful features, many of which make it easier to work with content on GitHub.com. USERNAME ˜MENTIONS Typing an @ symbol, followed by a username, will notify that person to come and view the comment.

1. Git configuration

  • Git config
    Get and set configuration variables that control all facets of how Git looks and operates.
    Set the name:
    $ git config --global user.name 'User name'
    Set the email:
    $ git config --global user.email 'himanshudubey481@gmail.com'
    Set the default editor:
    $ git config --global core.editor Vim
    Check the setting:
    $ git config -list
  • Git alias
    Set up an alias for each command:
    $ git config --global alias.co checkout
    $ git config --global alias.br branch
    $ git config --global alias.ci commit
    $ git config --global alias.st status

2. Starting a project

  • Git init
    Create a local repository:
    $ git init
  • Git clone
    Make a local copy of the server repository.
    $ git clone

3. Local changes

  • Git add
    Add a file to staging (Index) area:
    $ git add Filename
    Add all files of a repo to staging (Index) area:
    $ git add*
  • Git commit
    Record or snapshots the file permanently in the version history with a message.
    $ git commit -m ' Commit Message'

4. Track changes

  • Git diff
    Track the changes that have not been staged: $ git diff
    Track the changes that have staged but not committed:
    $ git diff --staged
    Track the changes after committing a file:
    $ git diff HEAD
    Track the changes between two commits:
    $ git diff Git Diff Branches:
    $ git diff List Branch:
    $ git branch --list Delete a Branch:
    $ git branch -d Rename Branch:
    $ git branch -m
  • Git checkout
    Switch between branches in a repository.
    Switch to a particular branch:
    $ git checkout
    Create a new branch and switch to it:
    $ git checkout -b Checkout a Remote branch:
    $ git checkout
  • Git stash
    Switch branches without committing the current branch. Stash current work:
    $ git stash
    Saving stashes with a message:
    $ git stash save '
    Check the stored stashes:
    $ git stash list
    Re-apply the changes that you just stashed:
    $ git stash apply
    Track the stashes and their changes:
    $ git stash show
    Re-apply the previous commits:
    $ git stash pop
    Delete a most recent stash from the queue:
    $ git stash drop
    Delete all the available stashes at once:
    $ git stash clear
    Stash work on a separate branch:
    $ git stash branch
  • Git cherry pic
    Apply the changes introduced by some existing commit:
    $ git cherry-pick

8. Merging

  • Git merge
    Merge the branches:
    $ git merge
    Continue the rebasing process:
    $ git rebase -continue Abort the rebasing process:
    $ git rebase --skip
  • Git interactive rebase
    Allow various operations like edit, rewrite, reorder, and more on existing commits.
    $ git rebase -i

9. Remote

  • Git remote
    Check the configuration of the remote server:
    $ git remote -v
    Add a remote for the repository:
    $ git remote add Fetch the data from the remote server:
    $ git fetch
    Remove a remote connection from the repository:
    $ git remote rm
    Rename remote server:
    $ git remote rename
    Show additional information about a particular remote:
    $ git remote show
    Change remote:
    $ git remote set-url
  • Git origin master
    Push data to the remote server:
    $ git push origin master Pull data from remote server:
    $ git pull origin master

10. Pushing Updates

  • Git push
    Transfer the commits from your local repository to a remote server. Push data to the remote server:
    $ git push origin master Force push data:
    $ git push -f
    Delete a remote branch by push command:
    $ git push origin -delete edited

11. Pulling updates

  • Git pull
    Pull the data from the server:
    $ git pull origin master
    Pull a remote branch:
    $ git pull
  • Git fetch
    Download branches and tags from one or more repositories. Fetch the remote repository:
    $ git fetch< repository Url> Fetch a specific branch:
    $ git fetch Github Cheat Code

    YAML
    YAML stands for “Yet Another Markup Language”. It’s a human-readable markup language commonly used for configuration files, especially by CI- and DevOps-focused software tools. GitHub Actions uses YAML as the basis of its configuration workflows.

    Workflow file
    The configuration file that defines your GitHub Actions workflow. This is written in YAML and lives inside your GitHub repository in the .github/workflows directory. Each file in that directory that is named with a .yaml extension will define a unique workflow.

    Example workflow file

    An explanation of this example workflow:

    name
    Calibre python 3. The name of your workflow will be displayed on your repository’s actions page.

    Github

    on
    The events that occur on GitHub that will cause your workflow to be executed. For example, you can run your workflow on push and pull_request triggers, which will let you build your code and run your tests in a Continuous Integration workflow. You can add additional constraints on these triggers, like running when certain files or changed or when a certain branch is pushed to.

    jobs
    A list of the jobs that run as part of the workflow. Each job will run independently of the others, and will run on a different virtual environment. Jobs may have a name to make them easily identifiable in the UI or in logs. Jobs contain a set of steps that will be executed, in order. This workflow has a single job, the build job.

    jobs.<job-id>.runs-on
    The type of runner to use to run the given job on, either a runner provided by GitHub or a self-hosted runner that you configure. GitHub provides three main types of runners: Linux (named ubuntu-latest), Windows (named windows-latest) and macOS (named macos-latest).

    jobs.<job-id>.steps
    A list of the steps that will run as part of the job. Each step will run one after another, all on the same virtual environment. By default, if any step fails then the entire job will stop. In this workflow, the build job contains three steps: Firefox version 68.0.2 download.

    1. The first step uses an action named actions/checkout@v2. This is an action provided by GitHub that will check out your repository onto the runner, so that it can be built and tested.
    2. The second step uses an action named actions/setup-node@v1. This is an action provided by GitHub that will set up a particular version of Node.js on the runner. Arguments can be provided to the action in the with section; in this example, the node-version argument is set to 12, which instructs the action to put Node.js version 12 in the PATH for subsequent steps.
    3. The final step runs programs on the command-line. By default, these programs will be run with bash (on Linux and macOS) or PowerShell (on Windows). A single command may be specified, or multiple commands can be specified by starting them with a leading pipe (|) symbol.
      In this case, a Node.js continuous integration build will be performed by running npm ci to download and install packages from the npm registry, then running npm run build to run the build script specified by the project, and finally running npm test to run any unit tests in the project.

    Github Cheat Sheet

    See all whitepapers →