Commands Flashcards
(35 cards)
Configure your username and email
git config –global user.name “Your name”
git config –global user.email “yourname@provider.com”
View git configurations
git config –list
How to initialize a repository
Create a folder and repository on GitHub and open the folder in the Terminal and use the command “git init”
instruct Git to link it with the remote repository
git remote add origin repo-url
If your remote repository already contains some code files, then you need to pull them inside your local repository
git pull
git init + git remote add origin repo-url + git pull
git clone repo-url [folder]
verify if a local repository is tracking the remote repository
git remote -v
replace the remote url
git remote set-url origin repo-url
This file contains files and folder names that should be ignored by Git while making commits.
.gitignore
move these files to the staging area
git add . || git add [filename] || git add -A || git add *
If you added some files in the staging area by mistake, then you can use the following command to unstage them
git reset [filename]
To create a commit, use the following command.
git commit -m “initial commit”
flag is used to insert a message that will describe the commit.
-m
All files shows _____ mode which means there are all new file.
create
To see all the commits in the repository (made by all the developers), use following command.
git log
To see file that was changed or added in a commit
git log –stat
To change the message of the previous commit
git commit –amend -m “Initial Commit”
You can avoid edit message dialog
git commit –amend –no-edit
to write and exit the vim editor
ESC + :wq
push that commit to the remote repository.
git push -u origin master
forget if commits after that ever existed
git reset –soft #
git reset –mixed #
git reset –hard #
You can use git ____ to see what code changes between the current state of the files and the state of the files in the previous commit.
diff
will set state of the above file to state of file in HEAD commit
git checkout – [filename]
If you have lots of untracked files or folders in the repository which you want to remove
git clean -f -d