Git
![[Screen Shot 2024-01-17 at 00.06.52.png]]![[Screen Shot 2024-01-17 at 00.07.36.png]]
Don't add untested features to main branch!
![[Pasted image 20240117082454.png]] 1. send files from our working directory to a staging level. 2. once we have a collection of related files in staging we want to save to the repo, we 'commit' those files along with a useful message explaining what was committed. 3. if we ever want a file or set of files back from the repository, we can do so using the 'checkout' process.
Commands¶
git init= create a new repotouch {file}= creates an empty file if a file does not exist.git add {file}= tells git to stage the file or directory for a commit, if it exists.git status= displays the state of the working directory and the staging areagit commit -m "Message"= Commit the files in staging to the repository; include a description message using the –m flaggit rm {file}= remove file from the working directorygit checkout HEAD {file}= get the deleted file back;HEADis a pointer to your most recent commit. This could also be the SHA value of any previous commit.git diff= see changesgit diff --cached {file}= see the difference between the staged version and the repository version, specify the --cached flaggit branch= list all current branches; current branch marked with *git branch {branchName}= create new branchgit checkout {branchName}= switch branchgit checkout -b {bName}= created the branch and switched to it in one command by specifying the -b flag to git checkout.git merge {bName}= merge the branch to current branchgit branch -d {bName}= delete the branchgit push -f: Force a push that would otherwise be blocked, usually because it will delete or overwrite existing commits (Use with caution!)git push -u origin [branch]: Useful when pushing a new branch, this creates an upstream tracking branch with a lasting relationship to your local branchgit push --all: Push all branchesgit push --tags: Publish tags that aren't yet in the remote repository