GitHub cheat sheet

Creating a warehouse ---- create a new warehouse or warehouses from acquiring an existing warehouse

 

$ git init [project-name]

Create a local repository and set the name or in the local folder $ git init

$ git clone [url]

Download a project and all its version history

Change ---- check the available editing and do a commit

$ git status

List all new or changed files that need to be submitted

$ git diff

Showing a document processing for a snapshot version control

$ git reset [file]

Remove files temporary area, but preserve the contents

$ git add [file]

The snapshot processing files for version control

$ git commit -m"[descriptive message]"

The permanent version history log file snapshot

Mass Change ---- naming a series of commitments and the merger completed work

$ git branch

List all of the local branch of the current warehouse

$ git branch [branch-name]

Create a new branch

$ git checkout [branch-name]

Switch to a specific branch and update the working directory

$ git merge [branch-name]

Merge the history of a particular branch to the current branch

$ git branch -d [branch-name]

Delete specific branch

Relocation and reconstruction of the file ---- remove version history

$ git rm [file]

Delete the file from the working directory and delete the staging

$ git rm --cached [file]

Remove files from version control, and save the file locally

$ git mv [file-original] [file-renamed]

Change the file name and is ready to submit

Stop tracking ---- does not include temporary files and paths

*.log

build/

temp-*

File Subtitle: .gitignore can prevent certain files into the version history

$ git ls-files --others --ignored --exclude --standard

List all items in the ignore file

Preservation of historical change ---- staging some unfinished changes have been hiding staging = (now want to switch branches as customers continue to upgrade, but you do not want to submit your work, so you can hide changes. To push a new hiding your stack, run git stash command)

Each of the files in your working directory are nothing more than these two states: tracked or not tracked. File tracking are those that were included in the document version control, we have their records on a snapshot, after working for some time, their status may be in unmodified, modified or placed in temporary storage area. Working directory all other files except the file has been tracking are all untracked files that are neither in the minutes of the last snapshot, nor into the staging area. First cloned a warehouse when all the files in the working directory files are all tracked and unmodified.

$ git stash

All that has changed is temporarily stored trace file

$ git stash pop

Recently restored all hidden files

$ git stash list

List all changes are hidden

$ git stash drop

Discard all recent changes hiding

Check history ---- browse files and examine development projects

$ git log

It lists the current version of the history of this branch

$ git log --follow [file]

Version History lists the files, including renaming

$ git diff [first-branch] .... [second-branch]

Show differences between two different branches

$ git show [commit]

And the specific contents of the input metadata commit changes

Undo commit ---- erase mistakes and change history

$ git reset [commit]

after revocation commit all commit, save your changes locally

$ git reset --hard[commit]

Discard all changes and return to a particular commit

Change ---- synchronization register a remote connection, the exchange warehouse version history

$ git fetch [remote]

All history download remote repository

$ git merge [remote]/[branch]

Consolidate the remote branch to the current branch

$ git push [remote] [branch]

Upload all local branches commit to github

$ git pull

Download bookmarks history and merge changes

Organize common actions

commit:

git commit

 

git branch:

git branch <branchname>

git checkout <branchname>

 

git go:

git merge <branchname>

merge the branchname to current branch

 

Go to rebase

take a series of commit records, copy them to another place

git rebase <another place>

current to another place

 

Git rebase <branchname1> <branchname2>

Copy name2 to name1

 

HEAD points to the latest record in the current branch

Split the head is means that let the HEAD points to the record rather than the branch name

 

Usint HEAD^ to move ahead

 

Git branch -f <branch> <place>

-f allows us to move the <branch> to <place>

 

Revert and reset

Git cherry-pick

Go to rebase

Individual common: to create a local warehouse in the folder and submit to GitHub

  1. cd path
  2. git init
  3. git add .
  4. git commit -m ‘message’
  5. git status
  6. git remote add origin respname
  7. git pull -rebase origin master the new warehouse readme files are merged into the local
  8. git push -u origin master the local repository project pushed to the remote repository (GitHub)

Guess you like

Origin www.cnblogs.com/shemlo/p/11608651.html