article

common git commands

[WHAT]

  1. ]  LIST of common git commands, each with a brief description, example command

[WHY]

  1. ] quick reference

[WHERE]

  1. ]

[WHEN]

  1. [2015-06-22]
    1. ] -v-001 - examples list pulled from main overview article, SECTION how to, replaced with link to this article

[EXAMPLE]

  1. ] USE "git init" - in your local "working directory"
    1. ] to create a local git repository,
    2. ] a repository is a hidden directory where git operates 
  2. ] USE "git status"  - to get status, example below
    1. ] # on branch master
    2. ] # initial commit
    3. ] # nothing to commit (create/copy files and use "git add" to track)
  3. ] CREATE or COPY files(your projects code) into the "working directory"
    1. ] ...
  4. ] USE status - example below, now shows files that have been added to the working directory
    1. ] # on branch master
    2. ] # initials commit
    3. ] # untracked files
      1. ] file.cs
      2. ] file2.cs
      3. ] ...
  5. ] USE "git add {filename} "  - to include what will be committed 
    1. ] git add file.cs
  6. ] USE status  
    1. ] # changes to be committed
  7. ] USE git rm --cached {file.cs}
    1. ] to remove file from what wil be committed
  8. ] USE git commit -m "description of change"
    1. ] to commit files that have been added to the repository
  9. ] USE git add with wildcards to add multiple files
    1. ] git add '*.txt'
  10. ] USE git log
    1. ] a journal that remembers all the changes we've committed so far, in the order we committed them.
  11. ] EXAMPLE git log
    1. ] commit b652edfd888cd3d5e7fcb857d0dabc5a0fcb5e28
    2. ] Author: Try Git try_git@github.com
    3. ] Date:   Sat Oct 10 08:30:00 2020 -0500
    4. ] Description: " feature 223 - hilight on change"
  12. ] ADD remote repositories
    1. ] We've gone ahead and created a new empty GitHub repository for you to use with Try Git at https://github.com/try-git/try_git.git.
    2. ] To push our local repo to the GitHub server we'll need to add a remote repository
    3. ] This command takes a remote name and a repository URL, which in your case is https://github.com/try-git/try_git.git.
  13. ] USE git remote add origin https://github.com/try-git/try_git.git
    1. ] Git doesn't care what you name your remotes, but it's typical to name your main one origin.
    2. ] It's also a good idea for your main repository to be on a remote server like GitHub in case your machine is lost at sea
  14. ] USE git push -u origin master
    1. ] Pushing Remotely - The push command tells Git where to put our commits when we're ready, and boy we're ready.
    2. ] So let's push our local changes to our origin repo (on GitHub).
    3. ] The name of our remote is origin and the default local branch name is master.
    4. ] The -u tells Git to remember the parameters, so that next time we can simply run git push and Git will know what to do.
  15. ] USE git pull origin master
    1. ] Let's pretend some time has passed. We've invited other people to our github project who have pulled your changes, made their own commits, and pushed them.
    2. ] We can check for changes on our GitHub repository and pull down any new changes by running: git pull origin master

[REFERENCE]

  1. ] BOOK - git started
    1. ] # 2459 - table of contents - a guide to learning git for noobs
  2. ] interactive git tutorial
    1. ] # # - you can practice these commands in a simulated environment, a tutorial by

 

Details Photos Edit more

Details

ID: 4574

NAME: git-commands

DESCRIPTION: ] LIST of common git commands, brief description, example command

AUTHOR: article.author/s

EDITOR: article.editor/s

PUBLISHER: article.publisher/s

STATUS: Write

PRIORITY: -5

OWNER ID: 75

Content Photos Edit more

photos

page_photo

actions

Email Email-Owner SMS and