Wednesday, November 18, 2015

Git Cheat-Sheet

From here on in, every command start with the 'git' followed by a space, then the command.
List of commands:
1. init
                The word init means initialize. The command sets up all the tools Git needs to begin tracking changes made to the project.
2. status
                As you write the screenplay, you will be changing the contents of the working directory. You can check the status of those changes
3. add 'filename.txt'
                add a file to the staging area
4. diff 'filename.txt'
                check the differences between the working directory and the staging area
5. commit -m "Some notes before committing"
6. log
                Commits are stored chronologically in the repository and can be viewed
7. show HEAD
                commit you are currently on is known as the HEAD commit
8. checkout HEAD filename
                discard a change and restore the file in your working directory to look exactly as it did when you last made a commit
9. add filename_1.txt filename_2.txt
                add multiple files to the staging area
10. reset HEAD filename.txt
                to unstage a file from the staging area
11. reset SHA
                rewind to the part before you made the wrong turn and create a new destiny for the project
To better understand git reset commit_SHA, notice the diagram on the right. Each circle represents a commit.
Before reset:
·         HEAD is at the most recent commit
After resetting:
·         HEAD goes to a previously made commit of your choice
·         The gray commits are no longer part of your project


·         You have in essence rewinded the project's history




12. branch
                Check what branch you are currently on.  In the output, the * (asterisk) is showing you what branch you’re on.
13. branch new_branch
                create a new branch







14. checkout branch_name
                 switch to the new branch
15. merge branch_name
                merging the branch into master
16. branch -d branch_name
                delete the specified branch from your Git project
17. clone remote_location clone_name
                cloning remote_location repository with new name clone_name
18. remote -v
                 see a list of a Git project's remotes.  You will need to cd to the clone_name repository
19. fetch
                will not merge changes from the remote into your local. It will bring those changes onto what's called a remote branch
20.  merge origin/master
                first, make sure to cd to the cloned repository.  Then git merge command to integrate origin/master into your local master branch
21.  branch <branch_name>
                create a branch to develop questions for the biology quiz
22.  checkout <branch_name>
                Switch to new branch
23. push origin your_branch_name
                push your branch up to the remote, origin.  Use what you created for a branch name in step


No comments:

Post a Comment