- Check status of your local repository. What are the possible states?
The three possible states of a repository are untracked, unmodified, modified and staged. We can check the status using git status. The status can be seen as lifecycle of our documents.
- How to view the history or log of your repository. Why is this useful?
You can check the log of a repository using the command git log inside the terminal. It shows the date and time, the author of the commit and an unique ID for the commit.
If we are using the web page, we can click on the clock icon named commit. If we click here it show the log of our repo. This is useful to check what other commits we have made and if we made a mistake we can go back in time to check what we had. Also, if we are collaborating in a project its easy to see others people contributions.
- Ensure you understand the states of objects in a repository (untracked, unmodified, modified, staged), see this diagram from the webpage resource at http://git-scm.com/book/en/v2/Git-Basics-Recording-Changes-to-the-Repository
Files can be in two states tracked or untracked. So when we upload our files to github these will be tracked and unmodified. Everytime we modified a file inside our repo this will change into modified state, then file changes to a staged file which mean is ready to be commited. When we commit the file returns to a unmodified states.
- Push changes to GitHub from your local repository
I modified locally a file and then push it using the terminal
- Pull changes from GitHub to your local repository.
- For the pull I forked the example repository called Spoon-Knife. I made a branch and then edit the readme. Once I made the changes I open a pull request.
- To understant how pull works. I used the git documentation:https://help.github.com/articles/using-pull-requests/
- Create an use Tags at the local repository level.
- Push and pull tags to the remote (GitHub) repository.
I created a tag called v0.1 and I pushed it to github.
I created another tag called v1.1 and pulled it to my local repo.
For leaning more about tags I used:
- Setup git aliases for your local configuration.
Aliases are keyboard shortcuts for git. Instead of typing git status we can only type git st. We can any alias like this:
git config --global alias.co checkout
I learned more about alias in here: https://git-scm.com/book/en/v2/Git-Basics-Git-Aliases
- Get git to ignore certain files. Why do we want to do this?
I created a .gitignore using the terminal, then I had to push it to my remote repository. I decided to ignore some .pyc and .DS_Store. This is useful if we have some byte codes or file that contains metadata from a OS. Also, if our project gets bigger ignoring elements like .class, .o, .pyc can be useful so every time we run git status we can concentrate only on those file that need to be tracked.
- Check out how Git is supported in your favorite editor. Does it just show information or does it have support for Git commands?
Atom have integration with git, we have some command like git status, we can check the head revision, diffs, etc. We cant do pull or commit with the current Atom core, but you can install a package called git-plus and you can perform those operations.