0% found this document useful (0 votes)
42 views9 pages

Git Day 2 PDF

The document discusses Git and GitHub concepts like local and remote repositories, fetching and pulling changes from remote repositories, the .gitignore file for ignoring files, and resetting commits. It also covers viewing hidden folders and removing accidentally tracked folders.

Uploaded by

yunus emre bey
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
42 views9 pages

Git Day 2 PDF

The document discusses Git and GitHub concepts like local and remote repositories, fetching and pulling changes from remote repositories, the .gitignore file for ignoring files, and resetting commits. It also covers viewing hidden folders and removing accidentally tracked folders.

Uploaded by

yunus emre bey
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 9

Git & GitHub

Recap

● Local and Remote Repository

● Practice committing and pushing

● Add à Commit à Push workflow

● More: Edit commit message, checkout commit


Git fetch, update, pull

● 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

● Updating will apply changes to the same branch


.git folder

● 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

● We can ignore files we don’t want to keep track of


● The .gitignore file allows you to define names of file/folders you don’t want
to keep track of changes for
● The .gitignore file is made like any other 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

- Add all the files you want to ignore tracking of

- Files to ignore in a java project:


- .idea, out, *.xml, *.iml
[EXTRA] How to remove folder that accidentally tracked
and pushed to GitHub

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:

Soft: file doesn’t update, but changes are staged automatically

Mixed: file doesn’t update, but changes are not staged automatically

Hard: file will lose all changes until the selected commit

Revert vs Reset: Revert is for pushed commits, history is perserved

You might also like