Removing Files you have added files to Git that you want it to track no longer.
Scenario: You added a file to Git accidentally or you may want to remove a file from current push
You cannot run git rm because you want to keep a copy of the file(git rm command will delete the file from file system)
Solution: To tell Git to stop tracking a file, but still keep it on your local system, run the following command
Expand
git rm --cached [file_name]
GIT - Ignore changes in a file
Expand
--Assume file to be unchanged
git update-index --assume-unchanged path/to/file.txt
GIT - Add all files that are tracked and has change
Scenario: I have modified large set of files and added new files as well and I want to stage only the tracked files. In such situations, I can use this command
Using Branches
Usage: List all of the branches in your repository.
Expand
2. git branch <new_branch>
Usage: Create a new branch called <new_branch>. This does not check out the new branch.
Expand
3. git branch -d <branch>
Usage: Delete the specified branch. This is a “safe” operation since Git prevents you from deleting the branch if it has unmerged changes.
Expand
4. git branch -D <branch>
Usage: Force delete the specified branch. Use this command only if you want to permanantly discard all unmerged changes
Expand
5. git branch -m <new_branch>
Usage: Rename the current branch to <new_branch>.
Expand
6. git clone git@yourrepositry.com:projectidentifier new-folder-name
Usage: Clone git repository to a folder with different name.
Usage: Resets your index and reverts the tracked files back to state as they are in HEAD.
Usage: Cleans untracked files.
Usage: Remove your .gitignored files and get back to a pristine state
Expand
10. git log branch_name..origin/branch_name
Usage: Find difference between my local branch and remote branch
GIT - Stash
Usage: Stash files for future reference
Usage: List stashed files
Usage: Show changes in stashed files
Expand
14. git stash save -p "message"
Usage: Lets you choose changes to be stashed, you can stash part of changes in a file as well