Git Day 2 PDF
Git Day 2 PDF
Recap
● To check if the remote repository has any changes that our local repository does not have,
we can fetch
○ Fetch will bring the new data without added to our local project right away
● To update your local repository with the new changes from the remote we can pull
○ Pulling is more flexible. We will see later
■ Branch to branch
● Local repositories are in the project in a folder called .git, which is a hidden
folder
● To see hidden folders on Mac, use this shortcut in the folder: Command +
Shift + .
● To see hidden folder on Windows, click on the View tab and show Hidden
items
Git Ignore File
● Note: You can not un-track a file already been tracked using .gitignore file.
That's why .gitignore file usually created before anything get staged.
Git in IntelliJ – git ignore
- To make a .gitignore file in the project right click on the project level -> create
new file -> call it .gitignore
Example: If you have accidentally pushed your .idea folder with many files in it, here is the
steps to untrack it.
- Go to IntelliJ terminal in bottom menu
- Type this command : git rm -r --cached .idea and hit enter
- if it is a file you may omit -r so it will be git rm --cached fileName
- This will remove .idea folder from local git repo and will not track it from this
point on.
- Make a commit and select all un-versioned files from commit window and
commit
- Push it back to remote and observe it's been removed from remote repo as well
Reset Commit
Right click on the commit you want to go back to and select Reset Current Branch
to Here
Git Reset options:
Mixed: file doesn’t update, but changes are not staged automatically
Hard: file will lose all changes until the selected commit