Git Tutorial
staged: Files are ready to be committed.
unstaged: Files with changes that have not been prepared to be committed.
untracked: Files aren't tracked by Git yet. This usually indicates a newly created file.
deleted: File has been deleted and is waiting to be removed from Git.
Staging Area: A place where we can group files together before we "commit" them to Git.
Commit A "commit" is a snapshot of our repository. This way if we ever need to look back at the changes we've made (or if someone else does), we will see a nice timeline of all changes.
add all: You can also type git add -A . where the dot stands for the current directory, so everything in and beneath it is added. The -A ensures even file deletions are included.
git reset: You can use git reset <filename> to remove a file or files from the staging area.
Note: The files listed in the Staging Area are not in our repository yet. We could add or remove files from the stage before we store them in the repository.
To store our staged changes we run the commit command with a message describing what we've changed:
  git commit -m "message here"
 git rm command which will not only remove the actual files from disk, but will also stage the removal of the files for us.
The '-a' option
If you happen to delete a file without using 'git rm' you'll find that you still have to 'git rm' the deleted files from the working tree. You can save this step by using the '-a' option on 'git commit', which auto removes deleted files with the commit.
git commit -am "Delete stuff"
Wildcards: We need quotes so that Git will receive the wildcard before our shell can interfere with it. Without quotes our shell will only execute the wildcard search within the current directory. Git will receive the list of files the shell found instead of the wildcard and it will not be able to add the files inside of the octofamily directory.
Check all the things!
When using wildcards you want to be extra careful when doing commits. Make sure to check what files and folders are staged by using git status before you do the actual commit. This way you can be sure you're committing only the things you want.
git remote
git remote add origin https://github.com/try-git/try_git.git
The name of our remote is origin and the default local branch name is master. 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.
https://try.github.io/levels/1/challenges/1
staged: Files are ready to be committed.
unstaged: Files with changes that have not been prepared to be committed.
untracked: Files aren't tracked by Git yet. This usually indicates a newly created file.
deleted: File has been deleted and is waiting to be removed from Git.
Staging Area: A place where we can group files together before we "commit" them to Git.
Commit A "commit" is a snapshot of our repository. This way if we ever need to look back at the changes we've made (or if someone else does), we will see a nice timeline of all changes.
add all: You can also type git add -A . where the dot stands for the current directory, so everything in and beneath it is added. The -A ensures even file deletions are included.
git reset: You can use git reset <filename> to remove a file or files from the staging area.
Note: The files listed in the Staging Area are not in our repository yet. We could add or remove files from the stage before we store them in the repository.
To store our staged changes we run the commit command with a message describing what we've changed:
  git commit -m "message here"
Wildcards: We need quotes so that Git will receive the wildcard before our shell can interfere with it. Without quotes our shell will only execute the wildcard search within the current directory. Git will receive the list of files the shell found instead of the wildcard and it will not be able to add the files inside of the octofamily directory.
Check all the things!
When using wildcards you want to be extra careful when doing commits. Make sure to check what files and folders are staged by using git status before you do the actual commit. This way you can be sure you're committing only the things you want.
git remote
git remote add origin https://github.com/try-git/try_git.git
git push
The push command tells Git where to put our commits when we're ready, and boy we're ready. So let's push our local changes to our origin repo (on GitHub).
The name of our remote is origin and the default local branch name is master. 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.
  git push -u origin master 
git pull
We can check for changes on our GitHub repository and pull down any new changes by running:
  git pull origin master
HEAD The HEAD is a pointer that holds your position within all your different commits. By default HEAD points to your most recent commit, so it can be used as a quick way to reference that commit without having to look up the SHA.
To see what is different from our last commit by using the git diff command.
In this case we want the diff of our most recent commit, which we can refer to using the HEAD pointer.
  git diff HEAD
Commit Etiquette: You want to try to keep related changes together in separate commits. Using 'git diff' gives you a good overview of changes you have made and lets you add files or directories one at a time and commit them separately.
git reset did a great job of unstaging file, but  he's still there. He's just not staged anymore.
Files can be changed back to how they were at the last commit by using the command: git checkout -- <target>
The '--'  : So you may be wondering, why do I have to use this '--' thing? git checkout seems to work fine without it. It's simply promising the command line that there are no more options after the '--'. This way if you happen to have a branch named octocat.txt, it will still revert the file, instead of switching to the branch of the same name.
git branch new_feature
git chechout new_feature
/*modifying the code...*/
git checkout master
git merge new_feature
git branch -d new_feature //delete branch
reference:
https://try.github.io/levels/1/challenges/1
http://git-scm.com/book/zh/v1/%E8%B5%B7%E6%AD%A5-Git-%E5%9F%BA%E7%A1%80
- 版权声明: 署名-非商业性使用(创意共享4.0许可证)
- 个人站: evilpan.com
- 博客园: cnblogs.com/pannengzhi/
- 公众号: 有价值炮灰
=== EOF ===
 
                    
                
 
                
            
         浙公网安备 33010602011771号
浙公网安备 33010602011771号