0% found this document useful (0 votes)
2 views2 pages

Git For Data Scientist

Git is a version control system that enables collaborative work on projects by tracking changes and managing code versions. Key concepts include repositories, commits, branches, and commands such as clone, pull, and push. The document also lists essential Git commands for managing files and repositories effectively.

Uploaded by

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

Git For Data Scientist

Git is a version control system that enables collaborative work on projects by tracking changes and managing code versions. Key concepts include repositories, commits, branches, and commands such as clone, pull, and push. The document also lists essential Git commands for managing files and repositories effectively.

Uploaded by

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

Git is a widely-used version control system that allows multiple people to work on a project

simultaneously without interfering with each other’s work. It keeps track of changes made to
files, enabling you to revert to previous states, collaborate efficiently, and manage code versions
effectively. Here are some key concepts and commands:

Key Concepts

1. Repository (Repo) .git: A Git repository is a directory that contains your project work,
including all the changes and the complete history of the project.
2. Commit: A commit is a snapshot of your repository at a specific point in time. It
represents a change or set of changes made to the files.
3. Branch: Branches are used to develop features, fix bugs, or experiment with new ideas
independently of the main project. The default branch is usually called main or master.
4. Merge: Merging is the process of combining changes from different branches.
5. Clone: Cloning is the process of creating a copy of an existing repository.
6. Remote: A remote is a common repository that all team members use to exchange their
changes. Examples include GitHub, GitLab, and Bitbucket.
7. Pull: Pulling is the process of fetching changes from a remote repository and merging
them into your local repository.
8. Push: Pushing sends your committed changes to a remote repository.

Git commands are run on the shell or terminal. To download git visit: https://git-scm.com/downloads

Git Commands:

1. pwd : current working directory


2. ls : list of all files in current dir., ls -a: shows even hidden files
3. cd dir_name: to switch to dir_name
4. nano file_name: to edit (delete,add,change content) file named file_name. Ctrl+O to save
changes and Ctrl+X to exit editor
5. echo name.txt : creates name file in current directory
6. echo “my name is Moin”>>name.txt : adds text to file
7. git –version: check current version of git
8. git add file_name: add file we are working on to Stagging area (modifiable), to add all files to
staging area use git add .
9. git commit –m “log message” file_name : to add file to commited area (non-modifiiable) with
log_message discussing changes
10. get status : check status of all files
11. echo/nano (editiors), add(stager), commit(submiited file)
12. git diff file_name : shows difference between current version(ustaged) of file vs last commited
13. git head –r HEAD file_name : shows difference between last stage of file vs last commited. Note
we can use ~n with HEAD to compare with n-1 last commit
14. git head –r HEAD: compares all staged vs last commit
15. git log : shows all commits made to repository. There are many other variations of this
command that can be used for specific purpose i.e git log –n returns n commits, git log –n file
returns n commits of specific file, git log --since=’Month Day Year’ –until=’Month Day Year’
16. git show ‘first 5 characters of hash’ : shows complete picture of a commit with that specific hash
(a unique id of each commit), git show HEAD~n shows details of n-1 last commit
17. git diff commit1hash commit2hash: difference b/w commit1,commit2
18. git diff HEAD~n HEAD~m: diff b/w n-1,m-1 commits
19. git annotate file: shows all commits to file in tabular form
20. git reset HEAD file_name : TO unstage a file, don’t add file_name to unstage all files
21. git checkout – file_name: to reset unstaged file to last commit, to reset all files use git checkout .
22. git checkout hashno. file_name: to reset to specific commit
23. git clean –n: show all untracked files
24. git clean –f: delete untracked files
25. git config –list : list of all configurable settings
26. git config --global settingvalue: to set a global setting i.e user.email xxx@xxx.com inplace of
setting value
27. nano .gitignore .*txt: git will ignore all txt files
28. git branch : displays list of branches, git checkout –b branch_name: adds a new branch in
current dir.
29. git checkout b1: switch to b1 branch
30. git merge source destination : merge two branches
31. git init repo_name: creates a new repo in current dir.
32. git init: turns current dir into repository
33. git clone url/location name : to get copy of a repo saved as name
34. git remote: tells source of a repos.
35. git remote add name url: saves repo as name
36. git remote –v: list of all remotes and their url
37. git fetch url/origin main: merge changes from remote(url) to main(loca) then use git merge
origin main to syncronise changes or use single command git pull origin main (merge/sync in one
command)
38. git push remote local_branch: merge local changes with remote one
39. see git cheatsheet on Datacamp

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy