Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Install /Set up GIT
- sudo apt-get install git # for debian\ubuntu users
- brew install git # for Mac users with Homebrew install
- Tell git who you are i.e Git username setting for every repository on your computer
- git config --global user.email "abc@example.com"
- git config --global user.name "your name"
- git config --global user.name . #confirm user
- Setting your Git username for a single repository
- Open Terminal.
- Change the current working directory to the local repository where you want to configure the name that is associated with your Git commits.
- Set a Git username:
- $ git config user.name "vivek singh"
- Confirm that you have set the Git username correctly:
- $ git config user.name
- > vivek singh
- git config --list #to return list of all user.
- ~/.gitconfig #look for git config file
- ~/.gitignore #look for git ignore
- git config --global color.ui true #To add command to git terminal
- Git:starting a repository
- git init
- git status
- git add . # add all files
- git rm --cached my-file.ts #to remove files from staging area
- git reset <file-name>
- commiting changes to git
- git commit -m "comment details"
- git commit -a -m "Do something once more" #add modified file and comment them
- how can you modify a file if you've already committed it?
- git reset --soft HEAD^
- Instead of resetting the HEAD and undoing the last commit, we can rectify a commit by using the "--amend" option when committing to a repository. Just add the remaining file to the staging area and then commit:
- $ git add file-i-forgot-to-add.html
- $ git commit --amend -m "Add the remaining file"
- #pulling anf pushing from and to repository
- git clone <clone>
- git pull
- git push -u origin master
- git remote add origin <link>
- #git commands for working woth branches
- git branch
- git branch branch-name #to add new branch
- git checkout branch-name
- git merge branch-name
- git branch -d branch-name
- git checkout -b development #create and switch to new branch
- git log #to check all commits in repository
- git show
- Usage: git show [commit]
- This command shows the metadata and content changes of the specified commit.
- git checkout -- #which will checkout all the modified files
- git reset --hard HEAD #to get rid of all the modifications made to tracked files made so far
- // or
- git reset --hard
- git stash #alternate to above reset command
- git stash will revert all the files to their previous version but whatever changes were made to these files will be saved in the stash list. This log can be seen using git stash list command.
- git stash apply stash@{0}
- git stash save #This command temporarily stores all the modified tracked files.
- git stash pop #This command restores the most recently stashed files.
- git stash list #This command lists all stashed changesets.
- git stash drop #This command discards the most recently stashed changeset.
- git clean -f -d #lots of untracked files or folders in the repository which you want to remove
- git revert commitno #to revert committed files
- git revert commitno --no-edit
- git diff #git difference between two commits.
- git command Alias
- git add -A && git commit -m "new changes"
- You can make an alias to this command in the Git using command below.
- git config --global alias.c "!git add -A && git commit -m"
- This will create a global alias c for command git add -A && git commit -m. Now you can use the command below
- git c "new changes"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement