Giter VIP home page Giter VIP logo

gitrain's Introduction

gitrain

Super basic stuff for beginners

git --version

git init

git status

git log

git branch -d branch_name

git remote add origin https://abc.com/abc.git
  • git log - view the history of commits
  • git branch -d branch_name - delete a branch
  • git remote add origin https://abc.com/abc.git - add a remote repository

This is the name you want to show up on your commits

git config user.name "Johnny test"

Stage all new, modified, and deleted files. Use the shorthand command

git add -A

Check the compact version of the status for repository

git status -s
git status --short

Commit the updated files directly, skipping the staging environment:

git commit -a -m "Commit message"

But only works for files that are already tracked by Git. New files must be added first.

Show all git possible commands in command line:

git help --all
git status --help

Create a new branch called hello-world-images

git branch hello-world-images

List the existing branches

git branch

Create and switch to a new branch called hello-world-images

git checkout -b hello-world-images
git merge --abort

remove the hello-you branch from the local repository

git branch -d hello-you

Add a remote repository as an origin

git remote add origin https://abc.com/abc.git

pull = fetch + merge

Pull the latest changes from the remote repository

git pull origin master

Get all the change history of the origin for this branch

git fetch origin

Merge the current branch with the branch master, on origin

git merge origin/master

or simpler

git pull origin master

Update the current branch from its origin using a single command:

git pull origin

push the current branch to its default remote origin

git push origin

List all local and remote branches of the current Git.

git branch -a

List only remote branches of the current Git.

git branch -r

Rename the origin remote to upstream

git remote rename origin upstream

this will rename the origin remote to upstream

show the name of the origin remote

git remote show origin

Git ignore

In .gitignore add a line to ignore all .temp files

*.temp

In .gitignore add a line to ignore all files in any directory named temp:

temp/*

In .gitignore, ignore all .log files, except main.log

*.log
!main.log

Add a new remote named ssh-origin connecting to x/y.git on abc.com using SSH

git remote add ssh-origin [email protected]:x/y.git

Replace the remote URL for origin with x/y.git on abc.com using SSH

git remote set-url origin [email protected]:x/y.git

Show the log of the repository, showing just 1 line per commit

git log --oneline

revert the latest commit

git revert HEAD

revert the latest commit, skipping the commit message editor

git revert HEAD --no-edit

revert the two last commits

git revert HEAD~1 HEAD

revert the THREE last commits

git revert HEAD~2 HEAD~1 HEAD

reset to the commit with the hash abc1234

git reset abc1234

Amend the previous commit to with the message "Updated index"

git commit --amend -m "Updated index"

amend is used to change the last commit message

gitrain's People

Contributors

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