GIT COMMANDS Flashcards
GIT CLONE (repository URL)
a command-line utility which is used to make a local copy of a remote repository. It accesses the repository through a remote URL.
GIT STATUS
The git status command is used to display the state of the working directory and the staging area. It shows which changes have been staged, which have not, and which files are not being tracked by Git. This command is important for understanding the current status of your project and for making informed decisions about your next steps. Mostly, it is used to display the state between Git Add and Git commit command.
GIT ADD <File></File>
selects that file, and moves it to the staging area, marking it for inclusion in the next commit. You can select all files, a directory, specific files, or even specific parts of a file for staging and commit.
GIT COMMIT -m <Message></Message>
The git commit command will save all staged changes, along with a brief description from the user, in a “commit” to the local repository.
Commits are at the heart of Git usage. You can think of a commit as a snapshot of your project, where a new version of that project is created in the current repository.
GIT PUSH
allows you to send (or push) the commits from your local branch in your local Git repository to the remote repository.
To be able to push to your remote repository, you must ensure that all your changes to the local repository are committed. After git pushes the changes to the remote repository other developers can access the changes and they can contribute their changes by git pulling.
GIT PULL
fetch and download content from a remote repository and immediately update the local repository to match that content.
The git pull command is actually a combination of two other commands, git fetch followed by git merge. it fetches the changes from remote and combined them with the local repository.
GIT CONFIG
The git config command is a convenience function that is used to set Git configuration values on a global or local project level. These configuration levels correspond to .gitconfig text files. Executing git config will modify a configuration text file. Can use to change username, email, password, or show Config values.
GIT BRANCH
The git branch command lets you create, list, rename, and delete branches. It doesn’t let you switch between branches or put a forked history back together again. A branch is a new/separate version of the main repository. Git Branch alone will list your branches. a * will appear next to the currently active branch
GIT CHECKOUT <Branch></Branch>
The git checkout command lets you navigate between the branches created by git branch . Think of it as a way to select which line of development you’re working on.
GIT LOG
The git log command displays committed snapshots. It lets you list the project history, filter it, and search for specific changes. While git status lets you inspect the working directory and the staging area, git log only operates on the committed history. You can see the hash of each Git commit, the message associated with each commit, and more metadata. This command is useful for displaying the history of a repository.
GIT STASH
git stash temporarily shelves (or stashes) changes you’ve made to your working copy so you can work on something else, and then come back and re-apply them later on. Stashing is handy if you need to quickly switch context and work on something else, but you’re mid-way through a code change and aren’t quite ready to commit.
the stash is local to your Git repository; stashes are not transferred to the server when you push.
GIT REBASE
apply any commits of current branch ahead of specified one. Git rebase is the linear process of merging. Gives a cleaner repository history.
GIT FETCH
The git fetch command downloads commits, files, and refs from a remote repository into your local repo. Fetching is what you do when you want to see what everybody else has been working on.
The most significant difference between “git pull” and “git fetch” is that “git pull” automatically merges the fetched changes into the current branch, while “git fetch” does not.
GIT MERGE
In the most frequent use cases, git merge is used to combine two branches. Merging is Git’s way of putting a forked history back together again. It integrates the history of these branches, ensuring that all changes are included and conflicts are resolved.
GIT RESET
The git reset command is used to undo the changes in your working directory and get back to a specific commit while discarding all the commits made after that one. For instance, imagine you made ten commits. Using git reset on the first commit will remove all nine commits, taking you back to the first commit stage.
Git Rest Soft – keep all changes.
Git Reset Mixed – keep working copy but reset index.
Git Reset Hard – discard all changes.